I've got the following code (I've removed the declare bits etc) and although it works, if the file is found it does an application.followhyperlink to the saved document, BUT it also creates a document called Dcoument1 which I don't need - how can i make sure this document1 doesn't load up?
instead of application.hyperlink I was using
.ActiveDocument.open strWordTemplate but that wasn't opening the saved version? it was opening a blank template again
any help much appreciated
Set txt = Me![txtSelectedTemplate].Column(0)
strWordTemplate = Nz(Me![txtSelectedTemplate])
Set cbo = Me![cboSelect]
If strWordTemplate = "" Then
GoTo ErrorHandlerExit
Else
strWordTemplate = Nz(Me![txtSelectedTemplate].Column(0))
End If
Set appWord = GetObject(, "Word.Application"
If Err.number = 429 Then
fIsWordRunning = False
Set appWord = CreateObject("Word.Application"
Err.Clear
Else
fIsWordRunning = True
End If
strLongDate = format(date, "dd-mm-yyyy"
strShortDate = format(date, "d-m-yyyy"
strDocsPath = dir_save
'strDocsPath = appWord.Options.DefaultFilePath(wdDocumentsPath) & "\"
strTestFile = Nz(Dir(strWordTemplate))
If strTestFile = "" Then
Exit Sub
End If
appWord.Documents.Add strWordTemplate
appWord.ActiveDocument.CustomDocumentProperties
On Error Resume Next
appWord.ActiveDocument.BuiltInDocumentProperties(2)
strSaveName = strDocType
'strSaveName = strDocType & " to " & _
' lst.Column(2, varItem) & " " & lst.Column(3, varItem)
strSaveName = Me.Text57 & Me.section1 & Me.txtSelectedTemplate & ".doc"
strSaveNamePath = strDocsPath & strSaveName
strTestFile = Nz(Dir(strSaveNamePath))
If strTestFile = strSaveName Then
Msgbox "Save name already used: " & strSaveName
Msgbox "Opening existing File", vbInformation
With appWord
application.FollowHyperlink strSaveNamePath
End With
instead of application.hyperlink I was using
.ActiveDocument.open strWordTemplate but that wasn't opening the saved version? it was opening a blank template again
any help much appreciated
Set txt = Me![txtSelectedTemplate].Column(0)
strWordTemplate = Nz(Me![txtSelectedTemplate])
Set cbo = Me![cboSelect]
If strWordTemplate = "" Then
GoTo ErrorHandlerExit
Else
strWordTemplate = Nz(Me![txtSelectedTemplate].Column(0))
End If
Set appWord = GetObject(, "Word.Application"
If Err.number = 429 Then
fIsWordRunning = False
Set appWord = CreateObject("Word.Application"
Err.Clear
Else
fIsWordRunning = True
End If
strLongDate = format(date, "dd-mm-yyyy"
strShortDate = format(date, "d-m-yyyy"
strDocsPath = dir_save
'strDocsPath = appWord.Options.DefaultFilePath(wdDocumentsPath) & "\"
strTestFile = Nz(Dir(strWordTemplate))
If strTestFile = "" Then
Exit Sub
End If
appWord.Documents.Add strWordTemplate
appWord.ActiveDocument.CustomDocumentProperties
On Error Resume Next
appWord.ActiveDocument.BuiltInDocumentProperties(2)
strSaveName = strDocType
'strSaveName = strDocType & " to " & _
' lst.Column(2, varItem) & " " & lst.Column(3, varItem)
strSaveName = Me.Text57 & Me.section1 & Me.txtSelectedTemplate & ".doc"
strSaveNamePath = strDocsPath & strSaveName
strTestFile = Nz(Dir(strSaveNamePath))
If strTestFile = strSaveName Then
Msgbox "Save name already used: " & strSaveName
Msgbox "Opening existing File", vbInformation
With appWord
application.FollowHyperlink strSaveNamePath
End With