C++/VB - excel automation
Asked By Wolf Grossi
21-Aug-09 05:40 AM
Hi,
doing excel automation I am running into the problem that a maro inside
some excel files can throw a
'Microsoft Visual Basic/Runtime error' messagebox.
As this happens in an automated process I want to prevent the
excel-macro from sending message boxes, maybe something similar to the
excel object attribute excel.DisplayAlerts = False.
I have no access to the execl files being processed, so I must handle
either the behavior of the excel macro or use some kind of 'hit the
button' function (AutoIT comes in mind), but I'd prefer doing this
within the VBScript.
Thanks for reding and hints
Wolf
...and tnx group, you already helped alot in the past...
AutoIT
(1)
Vbs
(1)
Appactivate
(1)
Sendkeys
(1)
Supress
(1)
Macros
(1)
mr_unreliable replied...

hi Wolf,
We may have to dig a little deeper into your script.
For example, if the macro is set up to run when you open your
worksheet, then there is not much you can do -- other than
react to the error dialogs.
OTOH, if you start the XL app and then run the macro later,
then you may have an opportunity to suppress the error dialogs.
I have never used the display alerts property, as I prefer to
get the vba errors out of the macros before using them in
production. And so, I am wondering whether you will be doing
yourself a favor by suppressing the error dialogs. In other
words, if there is really a "runtime error", then something
the original programmer was trying to do -- just is not working.
And charging ahead anyway will get you what???
As far as reacting to error dialogs, it is "possible" in vbs,
by using appactivate to check if the dialog is showing and
sendkeys to close it. However, you would be much better off
using some other scripting language (like AutoIt3, or many
others) which will give you more control over what you want
to do than appactivate and sendkeys.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
Wolf Grossi replied...
excel.DisplayAlerts = False
does not supress error messageboxes.
Absolutely agree that faulty apps must be corrected.
Unfortunately I have no access to the XL app, I have to process them as
they are.
Thanks for your comments,
Wolf

Definitely a Newbie- -Need an example C++ / VB I am told VBS comes with MS OSes, and that if I had an example script of a vbs program, I could see how it works by double clicking on the file. Does someone Python (1) Vista (1) Page (1) Perl (1) Nevada City CA (1) Relative (1) - -- -- -- -- -- -- -- --Demo.vbs- -- -- -- -- -- -- -- - MsgBox "Hello, World!" - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Useful link: http: / / technet.microsoft.com / en-us / scriptcenter / default.aspx Absolutely too. OK, I used notepad to put the line of text above into a a vbs file, tryit.vbs. Clicking on it twice only brought it up in Notepad. What is watch wrap? I speckledwithstars.net / > The wrap is that you put the code into a file called wolf.vbs.txt. Now if you make it wolf.vbs then it will work. Clicking it twice does not work. Notepad comes up. I am as - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- document.writeLn "Hello, World!" - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Another thing you can do is right click on a .vbs file, select - - Crash Atheism is a matter of faith, too. Dave, He is using notepad
Script works well, but not as scheduled tasks ? C++ / VB Hello everybody, I have a vbs script which shutdowns all PC in OU. This script works very well ! But, when I Yet, the configuration of the scheduled tasks seems to be correct : - Run : C: \ xxxxx \ script.vbs (it is OK !) - Run as : SERVER \ admin (account and password are OK !) Why does'nt batch file: @echo off echo %date% %time% %UserName% > > c: \ test.txt cscript / / nologo c: \ françois.vbs 1> > c: \ test.txt 2> > &1 echo %date% %time% > > c: \ test.txt 3. Remove the MVP] a ?crit : Ok, I have done this. Nothing takes place like with directly the vbs script. Here is the test.txt file : - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- mar. 13 / 10 / 2009 0:56:39, 15 in the as scheduled task, with a .bat file (like above) or directly with the vbs script (like in my firt message), I do not see processes of the "shutdonwn" command done exactly what you said. I am going to show you. 1) Here is my vbs script called shutdown.vbs. Notice that I removed the line "On Error Resume Next" as you said : - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ldap_adress = "LDAP called go.bat : - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @echo off echo %date% %time% %UserName% > > c: \ test.txt cscript / / nologo shutdown.vbs 1> > c: \ test.txt 2> > &1 echo %date% %time% > > c: \ test.txt - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3) I create
File association to a VBS C++ / VB Happy new year to everybody. . . . I got a small problem to associate a file extension to a vbs script (under XP). After file extension association to a VBS, if I click on the file, Windows XP display a message that the file is not a valid win32 application. . . . Is it possible to start a VBS with any file extension association ?? and how ?? Many thanks for any answer. . . VBScript Discussions Windows XP (1) Class (1) XP (1) Registry (1) Vbs script (1) Custom extension (1) File extension (1) HKCR (1) You have to associate the cscript followed by your script name, i.e. "c: \ path \ wscript.exe d: \ path \ script.vbs %1." I have never tried that specifically, but I associate a custom extension with an that you made up an unused extension and want it to be treated as a VBS file. I do not see the point. If you make it like a VBS then it is a VBS, so why not just call it VBS? In any case
VB6 (and Windows Scripting Host) Sendkeys in Vista and Windows 7 C++ / VB Microsoft has committed to support VB6 applications in Vista and Windows 7. However, it appears that support for VB Sendkeys is still lacking. The latest updates for Windows Vista and Windows 7 appear to support Sendkeys ONLY if UAC is turned off. For customers who use an older (VB6) version of when Microsoft will update Vista and Windows 7 so that VB6 (and Windows Scripting Host) Sendkeys will work as it does with UAC off. VB Vista Compatibility Discussions Windows Vista (1 7 (1) Vista (1) XP (1) VB (1) Form1.Text1 (1) SendInputNot (1) CmdSendKeys (1) SendKeys does still work. Can you explain how it is not working? Note that you cannot support VB6 applications in Vista and Windows 7. | | However, it appears that support for VB Sendkeys is still lacking. The | latest updates for Windows Vista and Windows 7 appear to support Sendkeys | ONLY if UAC is turned off. | | For customers who use an older (VB6) version of when Microsoft will update Vista and Windows 7 | so that VB6 (and Windows Scripting Host) Sendkeys will work as it does with | UAC off. Sendkeys seems to work fine once the
C++ / VB I have been given a DLL that I need to use in a VBS script. I have been told that it is just a DLL and NOT a COM C++ and VB !! Is there any method of using something like "LoadLibrary" or "LoadDLL" in VBS If so, will it work with the VBScript ASP Alternately, is there any way that ClassEx (1) Windows 7 (1) Perl (1) SfcMini.Structure (1) You cannot call it from VBS except possibly by using a COM component that allows you to call standard DLL methods to write an ActiveX (COM) DLL wrapper. The wrapper DLL would be designed to be VBS-compatible and to take care of any necessary data type conversion. It should ideally expose COM DLLs. The job is not hard. it is just a bit picky because what VBS "sees" needs to be straightforward and error-proof. And it needs to provide enough error info. for VBS to debug calls. I do not go along with "hokey". That's a pejorative and term. Granted ms did not have calling api's in mind when they offered up vbs, but they clearly "left- the-door-open" by providing vbs with the ability to interface with com objects. Once the com door is opened, anything