Solved

VB3 and MS Word

Posted on 1997-10-23
2
199 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 83
MS Date Picker 64 bit 32 bit issue 12 63
Help me. 3 69
how to Classify of email (pdf attachments) 7 49
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

685 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