?
Solved

Using automation from within VB App

Posted on 2006-06-14
1
Medium Priority
?
154 Views
Last Modified: 2010-04-30
I am using the following code to open a Word document from within my VB6 application.  This code works fine but sometimes when Word is loaded and the docment is displayed it is either minimized, behind my VB app or in front of the VB app.  Is their any way to force word to be opened normal and having the focus?                
               
                sPath = Me.SSOleDBGrid3.Columns(1).Text
               
                If UCase(Right(sPath, 4)) = ".DOC" Then
                    Set objApp = CreateObject("Word.Application")
                    Set objApp = GetObject(, "Word.Application")
                ElseIf UCase(Right(sPath, 4)) = ".xls" Then
                    Set objApp = CreateObject("Excel.Application")
                    Set objApp = GetObject(, "excel.Application")
                End If
               
                objApp.Visible = True
                objApp

                Set objDoc = objApp.Documents.Open(sPath)
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 17028469
You can set the WindowState property of the Word Application object to 0 (0=default 1=maximize 2=minimize).  But I'm not sure you're going to be able to keep the focus set on the Word application.  The next VB instuction is going to execute and I expect that's going to shift the focus back to the VB app.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question