Solved

VB3 and MS Word

Posted on 1997-10-23
2
175 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
ID: 1438556
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
ID: 1438557
Hi !

Thanks for the answer.

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

Regards PGG
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 42
Best way to parse out a json string in VB6? 10 109
Add and format columns in vb6 7 42
VB6 ListBox Question 4 30
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

932 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