Link to home
Start Free TrialLog in
Avatar of Spidercide
Spidercide

asked on

Win32 API's with VBScript, Lots o Points

I am trying to use Win32 API's with vbscript. Specifically I am trying to use FindWindowLike to see if I already have an instance of Excel open. In my travels I have learned that you can not access Win32 API's from vbscript(with good reason).
I know I have to create a secondary .ocx(control) file to enable me to access the win API functionality through an ActiveX control.

I was looking around and I found a nice solution at http://www.ahml.lib.il.us/pfw/VBS.html
He has a sample of how to do it, but it requires two other .ocx files and these files are not supplied.
He does tell you that they are in Tobias Weltner's book:
Windows Scripting Secrets.

This is good, unfortunatly the paperback didn't come with a CD and it had no text copies of the required files.
The two required files are "Clipboard.ocx" and "winmanag.ocx"

Do you know where I can find these files or is there ANOTHER way of finding out if an excel application is already open using vbscript?

I am posting 500 points at the moment, but will go up to 1000 if somebody can help me ut with this now(today)

Thanks in advance.
Avatar of _nn_
_nn_

What about looking for the process name ? Something like :

Set Wmi = getobject("winmgmts:")
Wql = "select * from Win32_Process where name='excel.exe'"
Set Processes = wmi.execquery(wql)
Wscript.Echo Processes.Count
For Each Process in Processes
    strProcessName = ("Name: " & Process.Name & ", PID: " & Process.ProcessID)
    Wscript.Echo strProcessName
Next

Disclaimer : I'm no VBScript coder, I gathered the above from various sites. Just hoping it'll help a bit.
Avatar of Spidercide

ASKER

No,

That won't do it. Yes I can 'find' it that way but I have no way of then 'connecting' to it or what not.

Basically I am trying to see if it is open then get the handle to the open workbook.
If not open then lauch it.

Enter information and then close it.
Thanks though.

ASKER CERTIFIED SOLUTION
Avatar of selim007
selim007

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I see. Sorry for the misunderstanding. As said, I'm no expert in the field, but as an apology, I did some research and found a couple interesting links, I hope it'll help a bit :

- http://www.borncity.de/WSHBazaar/ActiveX.htm has a control that lets you use FindWindow from VBscript
- http://www.borncity.de/WSHBazaar/WSHDynaCall.htm shows how to call any API in any documented dll (based on an old WSJ article)

Good luck.
I am accepting selim007 answer as the best. No information on hyow to do it, but that is what I needed. A little research and I was able to get it to work.
If you found the answer, can share it?

Thanks