Craig
Craig

Reputation: 155

VBscript Open Application and Save As different file type

I am in receipt of a number of JMP data table files (SAS related). I need to loop through a folder containing these files, open the file (via the file's native JMP application), and SAVE the file AS a SAS data set datatype. These JMP files can NOT be opened in SAS, hence the reason for having to open them in JMP software, then SAVEAS. There may be over a hundred of these JMP files, so I would like to automate the process. Here's the code I have so far:

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("Jmp.exe C:\SourceFolder\test.jmp")
'
wscript.sleep 8000
objShell.SendKeys "%{F}{A}"  '<-- FAILURE #1
wscript.sleep 8000
objShell.SendKeys "C:\DestinationFolder\test.sas7bdat{ENTER}"  '<FAILURE #2
wscript.sleep 8000
objShell.SendKeys "%{F}{X}"
'
Set objShell = Nothing

The application opens, but the SENDKEYS function does not open the SAVEAS popup. It only gets to FILE menu (this menu does drop down, but the "A" does not fire).

In addition, I will need to change the "save as type" file type option in the SAVEAS dialog as the file type defaults to ".jmp". This needs to be changed to ".sas7bdat". Simply saving the file with a new extension DOES NOT WORK.

NOTE: The JMP application I am using is a 30-day trial application. Not sure if that matters - however, I have tested opening/saving the file manually and it does indeed work.

Upvotes: 0

Views: 251

Answers (0)

Related Questions