VBA question when going from Win 2000 to XP

mtampa

Board Regular
Joined
Oct 15, 2007
Messages
61
We have a bunch of automated macro's that run on our computers at night here at work. I am not the person who built them, but simply the last person left in the office who can work with them. I just take old scripts and modify them to what I need, but am not always completely sure what I'm doing.

I'm getting the following error when I try to run my script on the XP machine:

Script: ........xyz
Line: 2
Char: 1
Error: Invalid procedure call or argument
Code: 800A0005
Source: Microsoft VBScript runtime error

It appears to me the part of my scrip the XP comp is getting upset with is the following:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("cm")

wscript.sleep 30000

Dim oAccessApp
Dim oExcelApp

'******************************************************
'****** WINTER 2010 ROOM INVENTORY ******
'******************************************************

Set oAccessApp = CreateObject("Access.Application")
oAccessApp.automationsecurity=1
oAccessApp.visible=true
oAccessApp.OpenCurrentDatabase("\\cgassv0001\revenue\DSS\DBs\Inventory\NAInv_w10.mdb")
oAccessApp.Run ("login")
oAccessApp.Run ("collect_Info_like_winter")
oAccessApp.Quit

wscript.sleep 5000

WshShell.AppActivate("Session A")
WshShell.SendKeys("%{F4}")


It runs just fine on a Win2000 machine, but not the XP machine. Does anyone know what needs to be modified?

Thanks!
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
Try this:

Open up the VBA code in the Win2000 machine, and from the Tool menu, select References. Note all the References that have been selected.

Now open up the the file in your XP machine and go to VBA and go to the same place and note any missing References. Make sure you select all the same References that the Win2000 machine has selected (it may be a newer version, but the name should be similar).
 

mtampa

Board Regular
Joined
Oct 15, 2007
Messages
61
Hey Joe, I appreciate your reply, but the file is actually in Notepad as opposed to Excel. Can I just dump the code in the VB editor in Excel and look at it that way?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
I should have looked a little closer. It looks like it is Windows Scritpting, and not an Excel question (BTW, NotePad is not a file type, it is just a Text Editor).

I have to admit that I am not all that experienced in Windows Scripting. I will move it to the appropriate forum.
 
Last edited:

mtampa

Board Regular
Joined
Oct 15, 2007
Messages
61

ADVERTISEMENT

Thanks man! I'm sorry for putting it in the wrong forum as well, I wasn't sure where to put it to start with.
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

Looks like a VBScript to me.

Go to your Windows 2000 machine and open up a console window (Windows Key +R followed by typing 'cmd' w/o quotes then Enter on an XP machine) and type 'cm' w/o quotes and hit Enter. What does it return?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
mtampa

This isn't a VBA problem, it's a problem with the script, which could be VBScript or some other flavour.

It might be worthwhile finding out what the script is meant to do and see if it's actually needed - perhaps what it does can be done solely in VBA.

And it looks like the problem is something to do with the script attempting to automate Access.

Perhaps automationsecurity isn't a method or property supported in XP.
 

mtampa

Board Regular
Joined
Oct 15, 2007
Messages
61
Hi

Looks like a VBScript to me.

Go to your Windows 2000 machine and open up a console window (Windows Key +R followed by typing 'cmd' w/o quotes then Enter on an XP machine) and type 'cm' w/o quotes and hit Enter. What does it return?


On the 2000 machine, it brings up a dos prompt, on the XP machine, it brings up an error. Just so you know, CM is the inventory system we use, which is located on each machine.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,499
Messages
5,596,515
Members
414,074
Latest member
Matthew Kakde

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top