Solved

VB3 and MS Word

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spell Check in VB6 13 148
vbModal 12 75
Collapse and expand table in Word 2010 2 161
VB6 - Check if date format = "MM/DD/YYYY' and check if date also exist 23 80
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

751 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