Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying A Word Document Through VB

Status
Not open for further replies.

Hackster

Programmer
Mar 28, 2001
173
US
I have the following code:
Code:
Private Sub Command3_Click()
Dim oWord As Word.Application
    Dim oDoc As Word.Document
    
    Set oWord = GetObject(, "Word.Application")
    If oWord Is Nothing Then
        Set oWord = CreateObject("Word.Application")
    End If
    
    oWord.Documents.Open FileName:="c:\labor.doc"
    oWord.Documents("labor.doc").Activate
    
    Set oDoc = oWord.ActiveDocument
    oWord.Visible = True
End Sub
It does a fine job of opening the document, but it is minimized, and I need to click on it to have it displayed on the screen. I would like to have it opened, and displayed on the screen, not minimized in the task bar. What am I doing wrong?
 
Hi,

I'm having trouble recreating your problem.

I used the code you provided and it opened the document as you wanted.

Harleyquinn
 
Thanks Harleyquinn. There must be something funky going on with my machine. Anyway, I like the shellexecute idea better than my own for two reasons: One, it does display the document, and two, I don't need to have a reference to the Word Object Library. (Thumbs up!)

Have a good one!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top