The following command is causing an error the first time the macro is run (the second time it works fine!)
AppWord.Dialogs(wdDialogFilePrint).Show
is causing the following error
Run-time error '5941':
The Requested Member of the Collection does not exist.
Any suggestions? I am establishing a reference to the Microsoft Word Object Library so that is not the problem and the command works fine the second time the macro is run! I am using the following code prior to the above line:
'create a new word instance
Dim AppWord As Object
Set AppWord = CreateObject("Word.Application")
'open file
AppWord.Documents.Open FileName:=TemplatesDir & InfoPack, PasswordDocument:=AdminPass
'set bookmarks
With AppWord
If CustomerName <> "" Then
.ActiveDocument.Bookmarks("CustName").Select
.Selection.typetext Text:=(CustomerName)
.ActiveDocument.Bookmarks("CustName2").Select
.Selection.typetext Text:=(CustomerName)
End If
End With
'display print dialog box
Application.ScreenUpdating = True
AppWord.Visible = True
AppWord.Dialogs(wdDialogFilePrint).Show[/i]
AppWord.Dialogs(wdDialogFilePrint).Show
is causing the following error
Run-time error '5941':
The Requested Member of the Collection does not exist.
Any suggestions? I am establishing a reference to the Microsoft Word Object Library so that is not the problem and the command works fine the second time the macro is run! I am using the following code prior to the above line:
'create a new word instance
Dim AppWord As Object
Set AppWord = CreateObject("Word.Application")
'open file
AppWord.Documents.Open FileName:=TemplatesDir & InfoPack, PasswordDocument:=AdminPass
'set bookmarks
With AppWord
If CustomerName <> "" Then
.ActiveDocument.Bookmarks("CustName").Select
.Selection.typetext Text:=(CustomerName)
.ActiveDocument.Bookmarks("CustName2").Select
.Selection.typetext Text:=(CustomerName)
End If
End With
'display print dialog box
Application.ScreenUpdating = True
AppWord.Visible = True
AppWord.Dialogs(wdDialogFilePrint).Show[/i]