Solved

VB3 and MS Word

Posted on 1997-10-23
2
168 Views
Last Modified: 2006-11-17
How to detect if Word is open, and specially how to 100 % being sure to activate it, and then open a specified file ?
Especially when the app is minimized, i can not make it to work, in other case it will often works ? I am using the following API functions :

   FindWindow("OpusAp...
   GetWindowText(Handle...
   AppActivate(...

And it works when Word is NOT in minimized state.

Thanks !
//pgg
0
Comment
Question by:pgg
2 Comments
 
LVL 3

Accepted Solution

by:
vmano earned 100 total points
Comment Utility
Hi pgg,
You can use the shellexecute function as described below.
Basically for the lpszFile$ parameter, just pass in the filename that you want to open for eg. "MYDOC.DOC".


   ' Enter the following three lines as one, single line:
   Declare Function ShellExecute Lib "SHELL" (ByVal hwnd%,   ByVal   lpszOp$,ByVal lpszFile$, ByVal lpszParams$, ByVal lpszDir$,      ByVal fsShowCmd%) As Integer

Here is a table providing descriptions for each parameter:

Parameter   Description

hwnd%       Identifies the parent window. This window receives   any message boxes an application produces (for example, for error
reporting).

lpszOp$     Points to a null-terminated string specifying the operation to perform. This string can be "open" or "print." If this parameter is NULL, "open" is the default value.

lpszFile$   Points to a null-terminated string specifying the file to open. lpszParams$ Points to a null-terminated string specifying parameters passed to the application when the lpszFile parameter specifies an executable file. If lpszFile points to a string specifying a document file, this parameter is NULL.

lpszDir$    Points to a null-terminated string specifying the default directory.

fsShowCmd% Specifies whether the application window is to be shown when the application is opened. This parameter can be one of the values described in the API ShowWindow().


Let me know if this helps.
bests,
vmano.


0
 

Author Comment

by:pgg
Comment Utility
Hi !

Thanks for the answer.

Sorry for the delay. Does this works with VB 3 ?
I will test it ?

Regards PGG
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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.
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…
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now