Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB3 and MS Word

Posted on 1997-10-23
2
Medium Priority
?
216 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
[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
2 Comments
 
LVL 3

Accepted Solution

by:
vmano earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
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

730 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