Solved

Win32 API's with VBScript, Lots o Points

Posted on 2003-11-10
7
13,596 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
[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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans

628 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