LJtechnical
Technical User
I have a button that should open a word template and continue with the vb code embedded in the template. Occasionally it works but for some reason I am getting Automation errors, I am lost as to why! Any Ideas?
Private Sub Command42_Click()
On Error GoTo Err_Command42_Click
Dim wrdApp As Object
Dim strFileNm As String
Set wrdApp = CreateObject("Word.Application"
wrdApp.Visible = True
With FileSearch
Do
.NewSearch
strFileNm = "Mapimport"
.MatchTextExactly = True
.LookIn = "C:\Program Files\Microsoft Office\Templates"
.SearchSubFolders = False
.Filename = Dir(strFileNm)
.Execute
Loop While .FoundFiles.Count = 0
End With
Documents.Add Template:="C:\Program Files\Microsoft Office" _
& "\Templates\Mapimport.dot"
Exit_Command42_Click:
Exit Sub
Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click
End Sub
Private Sub Command42_Click()
On Error GoTo Err_Command42_Click
Dim wrdApp As Object
Dim strFileNm As String
Set wrdApp = CreateObject("Word.Application"
wrdApp.Visible = True
With FileSearch
Do
.NewSearch
strFileNm = "Mapimport"
.MatchTextExactly = True
.LookIn = "C:\Program Files\Microsoft Office\Templates"
.SearchSubFolders = False
.Filename = Dir(strFileNm)
.Execute
Loop While .FoundFiles.Count = 0
End With
Documents.Add Template:="C:\Program Files\Microsoft Office" _
& "\Templates\Mapimport.dot"
Exit_Command42_Click:
Exit Sub
Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click
End Sub