Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Win32 API's with VBScript, Lots o Points

Posted on 2003-11-10
7
Medium Priority
?
13,612 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
6 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 1000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress

876 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