Solved

Win32 API's with VBScript, Lots o Points

Posted on 2003-11-10
7
13,569 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to setup 18 80
Visual xHarbour 1 77
java continue statement 10 75
how to update exe applicatio from internet ? 6 41
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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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…
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 …

746 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

11 Experts available now in Live!

Get 1:1 Help Now