I have a problem when trying to open a Word document via VBA code within Excel. The office environment is hosted as a VM (Office 2010 running on a virtual Windows 7 environment)
I've reduced the code to bare minimum to illustrate the problem. Code follows:
Dim NewDoc as Word.Document
Dim wdApp as Word.Application
set wdApp = New Word.Application
set NewDoc = wdApp.Documents.Add
... clean up
Executing the code via Excel VBA (not shown here) crashes with error 4248 "This command is not available because no document is open."
The line that is attempting to save the document is failing. Entering the debugger and inspecting NewDoc reveals that 'NewDoc = Nothing'.
Placing a breakpoint on the Documents.Add line and executing the code within the debugger, I can see that NewDoc is initialized to "Document1". Running the remaining code within the debugger correctly saves a Word doc named 'New.docx'!
If I port the code to a 'thick client' and run it locally it works fine. So, the problem is related to running within the VM.
Got me baffled :) Any ideas out there?