Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys Alternative

Status
Not open for further replies.

johnisotank

Technical User
Aug 8, 2008
258
GB
Hi all, desperately need some help for this please. I have an Excel macro which has been running on my XP machine fine for years. I have now switched to Windows 7 and the SendKeys function no longer works properly. I need a workaround please.

The code is supposed to 1. Send a print of my current sheet to the CutePDF Writer, 2. Change the location of where to save the file, 3. Press enter on the dialog box to print the file

Code is
Code:
Workbooks("Manpack Depot Reporter.xls").Activate
'Print to CutePDF
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"CutePDF Writer on CPW2:", Collate:=True
' Pause for x seconds
Pause (5)
' This line of code sends the filename characters and the ENTER key to the active application (i.e. the prompt window). The "False" statement allows the macro to continue running without waiting for the keys to be processed.
SendKeys "\\128.128.128.12\SharedDocs\ICT\Software\Manpack Scheduled Reports\Temp"
SendKeys "{ENTER}"

All that happens now (with Win7) is the print command gets actioned and the CutePDF Writer dialog box opens asking where to save the PDF. Steps 2 and 3 just dont happen. Any advice is really appreciated.

Thanks
John
 
The usual companion of SendKeys is AppActivate.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi, I wasn't able to get the program to change the directory to my temp folder (just seems to ignore sendkey for that). But instead I got it to save in default directory and then use this code to move the file

Code:
Rename "C:\my file.xls" As "C:\Temp\MyFile.xls"

But the AppActivate code was very helpful in getting it to work so thanks very much for that.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top