VBAstudent1977
New Member
- Joined
- May 12, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
Hello!
I would like to be able to open an existing Word document using Excel but name the word document in the Excel document and not the VBA code itself.
I have figured out how to open an existing Word document if I paste the path directly into the VBA code - but I'd like to define the path in the Excel document itself and have the VBA grab the path to be used when the macro is run. I am hoping to use this workbook for multiple reports and as a result I want the user to be able to enter the path of their document in Excel rather than have to understand VBA.
Right now my code (which is pretty basic as I'm new to writing VBA Code) to open an existing file is:
Sub OpenReport()
'Declare Word Variables
Dim WordApp As Word.Application
Set WordApp = CreateObject("Word.Application")
Dim strFile As String
strFile = "C:\Documents\Automated Reports\Report.docx"
WordApp.Documents.Open strFile
WordApp.Visible = True
End Sub
Any thoughts? Thank you!
I would like to be able to open an existing Word document using Excel but name the word document in the Excel document and not the VBA code itself.
I have figured out how to open an existing Word document if I paste the path directly into the VBA code - but I'd like to define the path in the Excel document itself and have the VBA grab the path to be used when the macro is run. I am hoping to use this workbook for multiple reports and as a result I want the user to be able to enter the path of their document in Excel rather than have to understand VBA.
Right now my code (which is pretty basic as I'm new to writing VBA Code) to open an existing file is:
Sub OpenReport()
'Declare Word Variables
Dim WordApp As Word.Application
Set WordApp = CreateObject("Word.Application")
Dim strFile As String
strFile = "C:\Documents\Automated Reports\Report.docx"
WordApp.Documents.Open strFile
WordApp.Visible = True
End Sub
Any thoughts? Thank you!