Open Word file form Excel using VBA and file path
I’m using an excel spreadsheet as an Add-in menu. Also in the same workbook is a sheet with the menu structure and paths to other excel files.
It’s working great using this:
Private Sub GetXLWorkbook()
Workbooks.Open CommandBars.ActionControl.Parameter, , True
Exit Sub
End Sub
Now I’m trying make it open word files as well using this:
Sub GetWordWorkbook()
Dim wordApp As Object
Dim wordDoc As Object
Set wordApp = CreateObject("Word.application")
wordApp.visible = True
Set wordDoc = wordApp.Documents.Open("C:\Example.doc")
End Sub
Opening word files does work if I run it manually but it does not work if I write the path in my excel menu? There is a problem with this path line:
Set wordDoc = wordApp.Documents.Open CommandBars.ActionControl.Parameter, ,
Hope someone can help.
KR Peter
Bookmarks