• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Can you launch a SAS program from an Access macro or VB code?

If it can be done, what is the syntax?  

  • 3
  • 3
1 Solution
Would this article help at all?  It looks like an example using VB Script.

You can give FollowHyperlink a try, otherwise you will find the shell command nested DEEP inside Brad's link would work if you construct your starting parameters correctly.

followhyperlink will work to launch most any file type that has an associated file type on your machine.

Worth a try

FollowHyperlink "path and file name with extension here"

c9k9hAuthor Commented:
Hi Jeff . . . you're still out there!  Haven't seen your name in awhile.

This is very cool!  It does open the SAS program.  This may be asking to much - but can it execute it?  Or perhaps I need to put the SAS program in a batch job and then run the batch job from Access.  Hmmm .....   Any suggestions?
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Hi Karen,
I have lots of ideas! If you want to run a batch job with it, consider a few things. You won't be using FollowHyperlink though.

1) The environment you're in when running the app/batch. If its local then it will be easy enough to write a batch script to execute your program file. But if you're term'ing in to a citrix or some other kind of session, you'll have to work out the credentials and scheduling with an administrator.

2) Maintenance. If you create a "Fixed" batch script or Shell() script, and the location, or parameters change, then you have to stay on top of that.

3) Who else will be doing this when you go on vacation to the Bahamas? Is it relatively user-proof once its all said and done?

4) Cost vs Convenience. Is it cost effective spending the time and resources trying to set this all up to be a timed job vs doing steps manually?

5) Your skillset. It should be something you are willing to take on and learn. And we all know what happens then, you become the expert. So be prepared to become the owner of your process.

Just some things to consider. Hope all is well...and yes, I've been extremely buried for a while,  so my time out here has been and will probably still be limited. But its good to see familiar names! :o)
c9k9hAuthor Commented:
You are the best, Jeff!  Great explanations - thank you for putting those together.  (Close on the vacation - it's the Cayman Islands!)

The softward I'm launching (SAS) is on my local machine so a batch job will work for now.  This process is a 'band-aid' for the time being while we work out a long term solution.  So again, I appreciate your details to consider.

I am currently using the FollowHyperlink method and launching the batch file.  The only think I don't like with this is that I had to take it out of the code and make it a separate button because the SAS job takes about 20 minutes to run.  The code behind the button in Access doesn't care how long the job takes, as soon as it makes the connection - as far as it's concerned . . . it's done.  So it goes on to the next step and can't find the file it's looking for (because SAS is sending it in), so it throughs an error.  Once I pulled it out as a separate step it's okay, but that's not my preference.  I'd like the user to be able to click the button and not do anything again until the whole process is complete.

If you have a quick work-around for that, I'd love to hear it.  But it is working - so I'm not dead in the water.

Again - thanks for all you help!!!
IF you want to wait for a process to finish, or for a file to appear in a specified location, you can definately be creative.

The first option I would think would be to look into a shell command that "listens" for a processed finished bit. I don't really use these as the environments I support have always been either server based or term or citrix, and that doesn't really play well.

Another thing you can do is put your app into a loop until a file appears in your directory.

Do until Dir("c:\myfile.xxx") <> ""

Use the sleep api to keep it from cycling all your CPU time waiting for the file to appear. Set the interval to whatever you want.

I might not have gotten the syntax just right, but I think you get the idea.

Put this at the top of a code module right underneath the Option statements

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim lmilliseconds As Long

IT should get you past your wait issues.

That all depends also if your app actually creates a file. So there ya go!
Enjoy, and have fun in the Caymans! lol
c9k9hAuthor Commented:
Thanks so much Jeff.  I will check this out.  I'm closing the post because you have already answered my original question.  I consider the rest a bonus!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now