Funcion getObject
Publicado por Bernardo (9 intervenciones) el 31/08/2018 14:18:39
Hola. Buscando una macro en la nume encontre esta
Funciona perfecto. Ahora cuando reemplazo la linea <<Const strpath = "C:\Users\NAME\Documents\Computer\VBA\SpdSheetNotes.doc">> por <Dim strpath As Sring> y asigno strpath = "ruta + archivo".No funciona.
1) Porque no encuentra el archivo
2) Cual es la sintaxis correcta.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Sub HelpAndInfo()
'Open Help and Information Document
Const strpath = "C:\Users\NAME\Documents\Computer\VBA\SpdSheetNotes.doc"
Dim Wd As Object
Dim HelpDoc As Object
Dim f As Boolean
On Error Resume Next
Set HelpDoc = GetObject(strpath)
If HelpDoc Is Nothing Then
Set Wd = GetObject(, "Word.Application")
If Wd Is Nothing Then
Set Wd = CreateObject("Word.Application")
If Wd Is Nothing Then
MsgBox "Failed to start Word!", vbCritical
Exit Sub
End If
f = True
End If
Set HelpDoc = Wd.Documents.Open(strpath)
If HelpDoc Is Nothing Then
MsgBox "Failed to open help document!", vbCritical
If f Then
Wd.Quit
End If
Exit Sub
End If
Wd.Visible = True
Else
With HelpDoc.Parent
.Visible = True
.Activate
End With
End If
End Sub
1) Porque no encuentra el archivo
2) Cual es la sintaxis correcta.
Valora esta pregunta


0