J2F
asked on
Need help with Excel VBA code to close a Word document.
I'm using 2010 versions of Excel and Word.
When my Excel workbook, TT.xlsm, is opened, Workbook_Open() calls a local Sub, OpenAWordDocument, which, in turn, opens a Word document.
I would appreciate some help developing a procedure to call from Workbook_BeforeClose() which will Save and Close the Word document without requiring operator intervention.
Thanks,
Tonkawa Jingles
When my Excel workbook, TT.xlsm, is opened, Workbook_Open() calls a local Sub, OpenAWordDocument, which, in turn, opens a Word document.
Sub OpenAWordDocument(Optional ByVal DocName As String = "", Optional ByVal DocPath As String = "")
Dim objWord As Object
If Len(Trim(DocName)) = 0 Then
DocName = "Word Document.docx"
End If
If Len(Trim(DocPath)) = 0 Then
DocPath = "D:\Documentation"
End If
If Right(DocPath, 1) <> Application.PathSeparator Then
DocPath = DocPath & Application.PathSeparator
End If
'Open an existing Word Document from Excel
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = True
.Documents.Open DocPath & DocName
End With
Set objWord = Nothing
End Sub[/indent][/indent][/indent]
I would appreciate some help developing a procedure to call from Workbook_BeforeClose() which will Save and Close the Word document without requiring operator intervention.
Thanks,
Tonkawa Jingles
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER