WD2000: Document Not Displayed with CreateObject ("Word.Document")ID: Q209892
|
When you use the Visual Basic for Applications CreateObject function to create a "Word.Document" object, the document is not visible.
For example:
Sub CreateDocObject()
Dim oDoc As Document
Set oDoc = CreateObject(Class:="Word.Document")
End Sub
This behavior is by design. The CreateObject function should only create the server object, not the document. In Word 97, creation and visibility of a new document by using the CreateObject function is not the expected behavior while within Word 97.
Microsoft provides programming examples for illustration only, without
warranty either expressed or implied, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to
provide added functionality or construct procedures to meet your specific
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
Sub CreateDocObject()
Dim oDoc As Document
Set oDoc = CreateObject(Class:="Word.Document")
oDoc.Paragraphs.Add
End Sub
Sub CreateDocObject()
Dim oDoc As Document
Set oDoc = CreateObject(Class:=”Word.Document”)
oDoc.Paragraphs.Add
oDoc.Application.Visible = True
End Sub
Additional query words: vba
Keywords : kbdta kbwordvba wd2000
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999