
Untitled
By: a guest on
May 10th, 2012 | syntax:
None | size: 1.08 KB | hits: 10 | expires: Never
Word cannot open this document template
Dim wdApp As New Word.Application
Dim wdDoc As Word.Document
Dim sFile As String
sFile = "C:document directorydocument.doc"
Set wdDoc = wdApp.Documents.Open(sFile)
If Not wdDoc Is Nothing Then
wdDoc.Close False
Set wdDoc = Nothing
End If
wdApp.Quit False
Set wdApp = Nothing
Dim wdApp As New Word.Application
Dim wdDoc As Word.Document
Dim sFile As String
sFile = "C:document directorydocument.doc"
wdApp.Visible = True
wdApp.DisplayAlerts = wdAlertsNone
On Error GoTo DidNotOpen
Set wdDoc = wdApp.Documents.Open(sFile)
On Error GoTo 0
wdApp.DisplayAlerts = wdAlertsAll
If Not wdDoc Is Nothing Then
wdDoc.Close True 'save the template change
Set wdDoc = Nothing
End If
GoTo Exit_Proc
DidNotOpen:
Set wdDoc = wdApp.Documents.Open(sFile) 'try again to see if it works
If Not wdDoc Is Nothing Then
wdDoc.AttachedTemplate = ""
End If
Resume Next
Exit_Proc:
wdApp.Quit False
Set wdApp = Nothing
End Sub