Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using active document

Status
Not open for further replies.

gwilym40

Programmer
May 2, 2002
31
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top