Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 20th, 2004, 02:03 PM
Registered User
 
Join Date: Jul 2004
Location: , Oklahoma, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Send Keystrokes to DOS Program from Access VBA

Is there anyway to launch a DOS Program and execute some keystrokes?

There is a DOS program I need to use but it is cumbersome. It involves entering some data paramaters and letting the program calculate something. The problem is I have multiple scenarios and it is tedious to enter all that over and over again (sometimes changing only one value).

I was wondering if there is a way to launch the DOS program from Access and enter the values from a table automatically into the DOS program?

Here's what I need to do in the DOS program.
  • DOS Program Starts
  • Press Enter to Continue
  • Name File
  • (Please Wait) - Program does something, I think it creates a file or something.
  • Enter Description
  • Enter M or E
  • Enter Y or N
  • Enter Value (Integer)
  • Enter Value (Integer)
  • Enter Value (Integer)
  • Enter Value (Integer)
  • Enter Value (Integer)
  • Enter Value (Integer)
  • Enter Y or N
  • Enter H or S
  • Enter Value (Integer)
  • Enter Value (Decimal)
  • Enter Value (Integer)
  • Enter Value (Decimal)
  • Enter –1 (To Finish)

I've tried
Code:
Dim retVal
retVal = Shell("C:\TNMLook\TNMLook.exe", 1)
AppActivate retVal

SendKeys "{Enter}", True
SendKeys "myfilenamehere{Enter}", True
SendKeys "mydescriptionhere{Enter}", True
SendKeys "MorEenteredHere{Enter}", True
AppActivate retValDOS Program opens but I get the following error message with the line below.
Code:
AppActivate retVal
Run-time error '5':
Invalid procedure call or argument.


Removing that line doesn't work either. When I do that, it actually opens the DOS Program twice now?! Then it enters a bunch of \s'...

Any ideas?


Reply With Quote
  #2 (permalink)  
Old July 20th, 2004, 11:11 PM
Authorized User
 
Join Date: May 2004
Location: , NH, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Take a look at using Macro Scheduler. I use it with windows and DOS programs daily.

Available for free download at www.mjtnet.com.

Latest version is 7.2.050 I think. Too many features to list here, but will allow you to open dos program, do keystrokes, monitor delays necessary to pause for processing, etc. Can be called from command line, or hot keys, or built in scheduler. Your application sounds like you would probably trigger this from a command line.
Reply With Quote
  #3 (permalink)  
Old July 21st, 2004, 10:31 AM
Registered User
 
Join Date: Jul 2004
Location: , Oklahoma, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob Hansen,

Thank you for that tip!
:)

It's too pricey though (https://www.mjtnet.com/index.mv?selectprd.html).
:(

I would like to find a VBA solution that way I can use the data in my Access table to create the DOS "runs" for the program.



Reply With Quote
  #4 (permalink)  
Old July 22nd, 2004, 08:58 AM
Registered User
 
Join Date: Jul 2004
Location: , Oklahoma, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found this (http://www.adyn.com/macro/summary.html). It's freeware, but I can't download it and use it at work. Thought I might pass the information along here. I have never used it so I don't know if it works or is any good.

As with any other freeware, please use at your own risk.

:)

Reply With Quote
  #5 (permalink)  
Old July 25th, 2004, 05:34 PM
Authorized User
 
Join Date: May 2004
Location: , NH, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One more comment on Macro Scheduler (www.mjtnet.com). "Pricey" is always relative. But, it also allows you to make compiled run time versions of the scripts and distribute for free, no licensing, users do not need copies of Macro Scheduler on systems. So if this is pricey because of multiple users, remember that the compiled versions reduces the cost per user dramatically.

Can also incorporate VBscript internal to the scripts you make with Macro Scheduler, not necessary to learn new languages.
Reply With Quote
  #6 (permalink)  
Old July 25th, 2004, 10:01 PM
Registered User
 
Join Date: Jul 2004
Location: , Oklahoma, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob,

"Pricey" is always relative - How true!
:D

Well, I just got a free copy of Macro Scheduler from .NET Magazine (albeit it is version 6.2). Gonna give that a try! Will let you know if it works!

Still have not been able to do it in VBA though.
:(

Reply With Quote
  #7 (permalink)  
Old May 15th, 2007, 06:24 PM
Registered User
 
Join Date: May 2007
Location: Deer Park, AL, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi everyone,

I ran across an interesting program that can schedule macros to run in a MS Access database. It works by clicking a few buttons to set the date/time, then set the macro name to run. It doesn’t require using Windows Scheduled Tasks which is good for me. Check it out: http://macros.subpacket.com/

Regards,
Steven


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run DOS file commands using vba? alastair Access VBA 2 August 12th, 2006 03:40 AM
Create/Add controls to Access Form: VBA program AccessBeginner Access VBA 1 October 13th, 2005 06:48 AM
Installing a access database program in VBA MDrumm Access 4 August 22nd, 2005 02:48 AM
Pass arguments to dos program gregquinn Beginning VB 6 1 December 10th, 2003 04:38 AM



All times are GMT -4. The time now is 01:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.