VB Automation2

I have a PC where I want to use the scheduled task manager tol open up a database. When I try to use an amended vbs file there is an error message appearing that states that the system can not find the file specified even though I have confirmed its location. Plus when I use the old vbs file that opens up the excel file as a test all that happens is that an excel workbook opens up but not the file I have specified.
f19lAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
Still using the same vbs?
Can you post this line? (or any other .run lines)

objShell.Run "C:\path to file\yourfile.xls"
0
f19lAuthor Commented:
Below is a copy of the code from the original vbs file which I changed so that it would open up a database:

Dim objShell:Set objShell=CreateObject("Wscript.Shell")
objShell.Run "Y:\Middle Office\DATABASE\P&L\Ldn_pl.mdb"
'may need to wait till it loads - increase the timer as necessary (millisecs)
wscript.sleep 5000
objShell.AppActivate "Window title" 'of the program's popup
objShell.SendKeys "~" 'send Enter key
Set objShell=Nothing

When I use this code to open up another databaase on my first PC it seems to work without any problems.
0
sirbountyCommented:
Is Y a mapped drive?
Is it mapped on the other system?
How is it scheduled?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

f19lAuthor Commented:
Y is a mapped drive to which the PC has access to. Everyday I open the database on the PC concerned and use it without any problems. The two PCs I have are both mapped to the same drives and so there should be no problem opening up databases or spreadsheets in either one, which I can do manually. I used the original vbs file in an autotask manager scheduler on the second PC as a test to see if it would open up the file specified, it only opened up an excel workbook but not the file itself.
0
sirbountyCommented:
If you run this outside the scheduled task - does it work at all?
0
f19lAuthor Commented:
When I run the first vbs file that opens the spreadsheet outside the scheduler the specified file is opened but when I run the second vbs file the specified database does not open. I just get the message that the system can not find the file specified.
0
sirbountyCommented:
Let's try passing it through the command interpreter...change this line:

objShell.Run "cmd /c Start Y:\Middle Office\DATABASE\P&L\Ldn_pl.mdb"
0
f19lAuthor Commented:
When I do that I get the message: Cannot find the file 'Y:\Middle (or one of its components). Make sure that the path and file name are correct and that all required libraries are available. It looks like it is having problems recognising the folder "Middle Office"; the space inbetween could be causing problems.
0
sirbountyCommented:
yep..the space..
try:

objShell.Run "cmd /c Start " & chr(34) & Y:\Middle Office\DATABASE\P&L\Ldn_pl.mdb" & chr(34)
0
f19lAuthor Commented:
An error message appears as follows:
Script: y:\Public\Software and Info\MidasAutoload.vbs
Line:2
Char: 44
Error: Expected Statement
Code: 800A0400
0
sirbountyCommented:
I missed a quote...sorry...

Dim objShell:Set objShell=CreateObject("Wscript.Shell")
sRun="cmd /c Start " & chr(34) & "Y:\Middle Office\DATABASE\P&L\Ldn_pl.mdb" & chr(34)
objShell.Run sRun
wscript.sleep 5000
objShell.AppActivate "Window title" 'of the program's popup
objShell.SendKeys "~" 'send Enter key
Set objShell=Nothing
0
f19lAuthor Commented:
A black screen appears with the header Y:\Middle Office\DATABASE|P&L|Ldn_pl.mdb followed by two lines of Y:\Public\Software and info>
0
sirbountyCommented:
Change this line...

sRun="cmd /k Start " & chr(34) & chr(34) & chr(34) & "Y:\Middle Office\DATABASE\P&L\Ldn_pl.mdb" & chr(34)


the /k will leave the window open after processing for better diagnosis...
0
f19lAuthor Commented:
I have done that but still the same situation but with an additional black screen titled C:\WINNT\system32\cmd.exe and only one line of Y:\Public\Software and info>
0
sirbountyCommented:
Sorry for the back-and-forth here...not sure why it's failing, but try it with this version...

sRun="cmd /k Start msaccess " & chr(34) & "Y:\Middle Office\DATABASE\P&L\Ldn_pl.mdb" & chr(34)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
f19lAuthor Commented:
It works now! Thanks.
0
sirbountyCommented:
Happy to help - thanx for the grade!! :^)
0
f19lAuthor Commented:
You deserved it.
0
f19lAuthor Commented:
Sirbounty,

One final question in relation to the task manager, what line of code do I need to add so that I can open an excel file say with out the message appearing asking me whether I want to enable macros? I can put this into another separate question if you wish?

f19l.
0
sirbountyCommented:
No need...I can tell you, unless you're willing to compromise security, or digitally sign your macros, you won't get around this 'feature'... : (

Sorry about that...
0
f19lAuthor Commented:
How do I go about digitally signing the macros?
0
f19lAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.