Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using automation from within VB App

Posted on 2006-06-14
1
Medium Priority
?
156 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
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…
Suggested Courses

618 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