Forum Discussion
Opening a Word document from an Excel spreadsheet
I want my Excel macro to open a Word document. I can open an Excel document from my Excel macro, and I can open a Word document from my Word macro, but I cannot open a Word document from my Excel macro. Is it possible?
YES, YES, YES! That works, Thank you so much.
5 Replies
- Olufemi7Iron Contributor
Helloaekbus,
Yes, it’s possible to open a Word document directly from an Excel macro. You just need to automate Word from within Excel using VBA. A simple example looks like this:
Sub OpenWordDoc()
Dim wdApp As Object
Dim wdDoc As Object
Dim docPath As String
' Full path to your Word document
docPath = "C:\Users\YourName\Documents\Example.docx"
' Create a new Word application instance
Set wdApp = CreateObject("Word.Application")
' Open the document
Set wdDoc = wdApp.Documents.Open(docPath)
' Make Word visible
wdApp.Visible = True
End Sub
CreateObject(“Word.Application”) starts Word from Excel.
Documents.Open(docPath) opens the file.
wdApp.Visible = True ensures you can see Word; otherwise, it runs hidden.
If Word is already running and you want to attach to that instance instead of starting a new one, you can use:
Set wdApp = GetObject(, "Word.Application")
This way, your Excel macro can open and even interact with Word documents seamlessly.
- aekbusBrass Contributor
This procedure worked all except the Visible = true. I have screenprinted the Properties window and the sub as I changed it to my variable names and pasted them into a Word document and will attach it if I can figure out how. Comment: This procedure is not helpful to the user if they cannot see the document. (Few computer skills)
- aekbusBrass Contributor
YES, YES, YES! That works, Thank you so much.
- NikolinoDEPlatinum Contributor
Below are two simple approaches, starting with the easiest and then a slightly more flexible one.
Just want to open Word
This method simply tells Excel to open the Word file, just as if you double-clicked it.
Sub OpenWordDocument() Dim wordFilePath As String wordFilePath = "C:\YourFolder\YourDocument.docx" If Dir(wordFilePath) <> "" Then Workbooks.Open wordFilePath Else MsgBox "File not found." End If End SubThis works because Windows knows Word files must be opened by Microsoft Word.
Want to edit or automate Word
This method starts Word explicitly, opens the document, and gives you control over Word if you need it later.
Enable Word reference (optional but helpful)
In the VBA Editor, click Tools → References
Check Microsoft Word xx.x Object Library
Click OK
This gives you IntelliSense and better error checking.
Sub OpenWordDocument() Dim wdApp As Object Dim wdDoc As Object Dim wordFilePath As String wordFilePath = "C:\YourFolder\YourDocument.docx" ' Start Word Set wdApp = CreateObject("Word.Application") wdApp.Visible = True ' Open the document Set wdDoc = wdApp.Documents.Open(wordFilePath) End SubMy answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.