Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 20th, 2004, 02:03 PM
Registered User
 
Join Date: Jul 2004
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?


 
Old July 20th, 2004, 11:11 PM
Authorized User
 
Join Date: May 2004
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.
 
Old July 21st, 2004, 10:31 AM
Registered User
 
Join Date: Jul 2004
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.



 
Old July 22nd, 2004, 08:58 AM
Registered User
 
Join Date: Jul 2004
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.

:)

 
Old July 25th, 2004, 05:34 PM
Authorized User
 
Join Date: May 2004
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.
 
Old July 25th, 2004, 10:01 PM
Registered User
 
Join Date: Jul 2004
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.
:(

 
Old May 15th, 2007, 06:24 PM
Registered User
 
Join Date: May 2007
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







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 05:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.