Glory
Well-known Member
- Joined
- Mar 16, 2011
- Messages
- 640
Code:
Private Sub test()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
'==================================================<o:p></o:p>
'Procedure-level declarations<o:p></o:p>
'==================================================<o:p></o:p>
<o:p> </o:p>
Dim newHelp As Word.Application, theDate, thePath As String<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
'==================================================<o:p></o:p>
'Sets the path, the date, and the application object<o:p></o:p>
'==================================================<o:p></o:p>
<o:p> </o:p>
thePath = ThisWorkbook.Path
<o:p> </o:p>
Set newHelp = CreateObject("Word.Application")<o:p></o:p>
<o:p> </o:p>
newHelp.Visible = True<o:p></o:p>
<o:p> </o:p>
'==================================================<o:p></o:p>
'Opens Word, creates a new document, saves the file<o:p></o:p>
'==================================================<o:p></o:p>
<o:p> </o:p>
newHelp.NewDocument.Add (thePath & "Name.doc")<o:p></o:p>
<o:p> </o:p>
End Sub
This code successfully creates a Word window but doesn't create a document.
I've had this problem before when opening a browser window and trying to get a macro to do work in that window. It was necessary to use doevents and readystate and busy properties, but Word doesn't support those properties.
Any suggestions?