Solved

Using automation from within VB App

Posted on 2006-06-14
1
150 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

803 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