Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > VBScript
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 5th, 2003, 12:38 PM
Registered User
Join Date: Jul 2003
Location: Crawfordsville, Indiana, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default SendKey commands

I'm am using SendKey commands in Excel. But cannot get them to work as they should.
 Set WshShell = WScript.CreateObject("WScript.Shell")
 WshShell.Run "Excel"
 WScript.Sleep 500
 WshShell.AppActivate "Microsoft Excel"
 WshShell.SendKeys "%+(t)"
 WScript.Sleep 250
 WshShell.SendKeys "m"
 WScript.Sleep 250
 WshShell.SendKeys "~"
 WScript.Sleep 250
 WshShell.SendKeys "~"

I'm using this little bit of script to open Excel and then go to the Macro command and run the first macro
Excep where I have WshShell.SendKeys "%+(t)" I tried using the Excel hot key to run the Macro Alt+F8 WshShell.SendKeys "^{F8}", but that didn't work. Then I tried the the Excel command to open the menu bar and go to "T" for tools then down to "M" for macro. Alt+T M. or WshShell.SendKeys "^{T}"
WScript.Sleep 250
 WshShell.SendKeys "m"

That doesn't work either

Why can't I use SendKeys with the Excel hotkeys?

Reply With Quote
  #2 (permalink)  
Old July 6th, 2003, 02:30 PM
Authorized User
Join Date: Jul 2003
Location: Reading, Berkshire, United Kingdom.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read

Hi Charlie, try this method as it'll be more efficient & you won't have to rely on sendkeys: :)
Dim objXLApp
Set objXLApp = CreateObject("Excel.Application")

objXLApp.Workbooks.Open "C:\Book1.xls"
objXLApp.visible = true
objXLApp.DisplayAlerts = False

objXLApp.Run "Book1.xls!Macro1"

objXLApp.DisplayAlerts = True
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Python's commands: Help Static Python 3 March 26th, 2015 12:34 AM
ABOUT AT COMMANDS bobwith5 Visual Basic 2005 Basics 1 October 31st, 2007 02:25 PM
sql commands dr BOOK: Beginning Ruby on Rails 1 April 27th, 2007 12:22 PM
Sendkey not working kimb Excel VBA 3 March 14th, 2006 06:58 PM
Using 2 SQL commands attipa Classic ASP Databases 2 September 20th, 2003 05:23 PM

All times are GMT -4. The time now is 08:56 PM.

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