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!

Running Calculator Demo with Macro

Status
Not open for further replies.

Sparky1157

Programmer
Aug 19, 2016
30
US
I copied the following code from a Microsoft website which demonstrates how the Calculator can be invoked from a macro:

Dim ReturnValue, I
ReturnValue = Shell("CALC.EXE", 1) ' Run Calculator.
AppActivate ReturnValue ' Activate the Calculator.
For I = 1 To 100 ' Set up counting loop.
SendKeys I & "{+}", True ' Send keystrokes to Calculator
Next I ' to add each value of I.
SendKeys "=", True ' Get grand total.
SendKeys "%{F4}", True ' Send ALT+F4 to close Calculator.

However, when running the script it errors out on line:
AppActivate ReturnValue

I tried running this under the Extra! Macro Editor and the Visual Basic 6.5 Editor - both attempts failed at the same point. I don't have enough background knowledge to know what's wrong....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top