Reputation: 101
I am having trouble getting Excel to open a Word document, I keep getting runtime error 5174. I can't seem to find the problem, and the path seems to be correct.
The code line erroring out is documents.open line, in the code below:
'Instantiate Word and open the "Transfer price" document.
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open("C:\Users\SIDVI\Desktop" & "\" & "stWordDocument")
Upvotes: 0
Views: 227
Reputation: 23974
Your statement to open the file should be:
Set wdDoc = wdApp.Documents.Open("C:\Users\SIDVI\Desktop\" & stWordDocument)
By placing stWordDocument
in double-quotation marks, you were making it a String literal instead of a variable, and therefore you were trying to open the actual file called "C:\Users\SIDVI\Desktop\stWordDocument"
.
Upvotes: 1