Solved

Win32 API's with VBScript, Lots o Points

Posted on 2003-11-10
7
13,577 Views
Last Modified: 2013-11-13
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.
0
Comment
Question by:Spidercide
7 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9717839
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.
0
 

Author Comment

by:Spidercide
ID: 9718224
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.

0
 
LVL 2

Accepted Solution

by:
selim007 earned 500 total points
ID: 9720604
hi,
why don't you build your own dll ?? and make it return what ever you need ??
then use the createobject method to use it.
if u can't do it i'll build it for u.
0
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.

 
LVL 16

Expert Comment

by:_nn_
ID: 9721390
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.
0
 

Author Comment

by:Spidercide
ID: 10316455
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.
0
 

Expert Comment

by:young_nacs
ID: 12487547
If you found the answer, can share it?

Thanks
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

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 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

18 Experts available now in Live!

Get 1:1 Help Now