Solved

Using automation from within VB App

Posted on 2006-06-14
1
148 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
1 Comment
 
LVL 76

Accepted Solution

by:
David Lee earned 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now