SendKeys in Excel 97 
Author Message
 SendKeys in Excel 97

hi all

i am trying to click the chart wizard button
in Excel 97 with a VBS via sendkeys

has anyone else done this this before ?
could anyone suggest a method of doing this

any help would be gratefully appreciated

many thanks



Thu, 17 Feb 2005 01:49:10 GMT  
 SendKeys in Excel 97

You could open wizard via menu: send "Alt+i" then "h"

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

  hi all

  i am trying to click the chart wizard button
  in Excel 97 with a VBS via sendkeys

  has anyone else done this this before ?
  could anyone suggest a method of doing this

  any help would be gratefully appreciated

  many thanks



Thu, 17 Feb 2005 06:32:47 GMT  
 SendKeys in Excel 97

Are you wanting to display the ChartWizard, or automate it?

If you want to automate, something like this would do it:

Const xlLine = 4

Set xl = CreateObject("Excel.Application")
set wb = xl.Workbooks.Add
Set Sheet = wb.ActiveSheet
xl.Visible = True

Sheet.Cells(1,2).Value = 20
Sheet.Cells(1,3).Value = 25
Sheet.Cells(1,4).Value = 30
Sheet.Cells(1,5).Value = 35
Sheet.Cells(1,6).Value = 30
Sheet.Cells(1,7).Value = 25
Sheet.Cells(1,8).Value = 20
set rng = Sheet.Range("A1").Resize(20,10)
set Chart = Sheet.Parent.Charts.Add
Chart.ChartWizard rng, xlLine, , , , , _
 True, "Year", "Year", "Sales"

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com


  You could open wizard via menu: send "Alt+i" then "h"

  --
  Gurgen Alaverdian
  http://www.gurgensvbstuff.com

    hi all

    i am trying to click the chart wizard button
    in Excel 97 with a VBS via sendkeys

    has anyone else done this this before ?
    could anyone suggest a method of doing this

    any help would be gratefully appreciated

    many thanks



Thu, 17 Feb 2005 13:38:54 GMT  
 SendKeys in Excel 97



Are you wanting to display the ChartWizard, or automate it?

If you want to automate, something like this would do it:

Const xlLine = 4

Set xl = CreateObject("Excel.Application")
set wb = xl.Workbooks.Add
Set Sheet = wb.ActiveSheet
xl.Visible = True

Sheet.Cells(1,2).Value = 20
Sheet.Cells(1,3).Value = 25
Sheet.Cells(1,4).Value = 30
Sheet.Cells(1,5).Value = 35
Sheet.Cells(1,6).Value = 30
Sheet.Cells(1,7).Value = 25
Sheet.Cells(1,8).Value = 20
set rng = Sheet.Range("A1").Resize(20,10)
set Chart = Sheet.Parent.Charts.Add
Chart.ChartWizard rng, xlLine, , , , , _
 True, "Year", "Year", "Sales"

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com


You could open wizard via menu: send "Alt+i" then "h"

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

hi all

i am trying to click the chart wizard button
in Excel 97 with a VBS via sendkeys

has anyone else done this this before ?
could anyone suggest a method of doing this

any help would be gratefully appreciated

many thanks

Ok, many thanks for that.

but to be honest about it, i'm actually trying
to open the Flight Simulator in Excel 97

this is what i have so far

Dim objXL
Dim objXLchart
Set objXL = WScript.CreateObject("Excel.Application")
objXL.Visible = TRUE
objXL.WorkBooks.Add
'objXL.SendKeys "{74}", True
' Wscript.Sleep 100
objXL.Range("X97:L97").Select
Wscript.Sleep 50
objXL.SendKeys "{09}", True 'Tab key
Wscript.Sleep 50 '
objXL.SendKeys "{11}" , True 'Ctrl key
objXL.SendKeys "{10}" , True 'Shift key
'objXL.SendKeys "{Charts.Add}" , True ' causes error
'objXL.Charts.Add() ' doesnt work for this project
'Wscript.Sleep 3000 ' time spent in simulator
'objXL.SendKeys "{1B}", True 'Esc key

i think one of the problems also is the fact that
i need to send all the keys at once, not individually

thanks for any help, i appreciate it !



Thu, 17 Feb 2005 18:55:48 GMT  
 SendKeys in Excel 97
I do not think it is possible in a script. To bring this "egg" up you need to actually click on the chart button. Adding chart or
using the menu will not do. What make it worse, is that you need to hold simultaneously Ctrl+Shift and left mouse click. AutoIt
has got the mouse-click using application window coordinates but I doubt it can send key combination at the same time. At best you
could save a spreadsheet with selected range and M97 in focus.

regards,
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:



> Are you wanting to display the ChartWizard, or automate it?

> If you want to automate, something like this would do it:

> Const xlLine = 4

> Set xl = CreateObject("Excel.Application")
> set wb = xl.Workbooks.Add
> Set Sheet = wb.ActiveSheet
> xl.Visible = True

> Sheet.Cells(1,2).Value = 20
> Sheet.Cells(1,3).Value = 25
> Sheet.Cells(1,4).Value = 30
> Sheet.Cells(1,5).Value = 35
> Sheet.Cells(1,6).Value = 30
> Sheet.Cells(1,7).Value = 25
> Sheet.Cells(1,8).Value = 20
> set rng = Sheet.Range("A1").Resize(20,10)
> set Chart = Sheet.Parent.Charts.Add
> Chart.ChartWizard rng, xlLine, , , , , _
>  True, "Year", "Year", "Sales"

> --
> Please respond in the newsgroup so everyone may benefit.
> http://dev.remotenetworktechnology.com



> You could open wizard via menu: send "Alt+i" then "h"

> --
> Gurgen Alaverdian
> http://www.gurgensvbstuff.com


> hi all

> i am trying to click the chart wizard button
> in Excel 97 with a VBS via sendkeys

> has anyone else done this this before ?
> could anyone suggest a method of doing this

> any help would be gratefully appreciated

> many thanks

> Ok, many thanks for that.

> but to be honest about it, i'm actually trying
> to open the Flight Simulator in Excel 97

> this is what i have so far

> Dim objXL
> Dim objXLchart
> Set objXL = WScript.CreateObject("Excel.Application")
> objXL.Visible = TRUE
> objXL.WorkBooks.Add
> 'objXL.SendKeys "{74}", True
> ' Wscript.Sleep 100
> objXL.Range("X97:L97").Select
> Wscript.Sleep 50
> objXL.SendKeys "{09}", True 'Tab key
> Wscript.Sleep 50 '
> objXL.SendKeys "{11}" , True 'Ctrl key
> objXL.SendKeys "{10}" , True 'Shift key
> 'objXL.SendKeys "{Charts.Add}" , True ' causes error
> 'objXL.Charts.Add() ' doesnt work for this project
> 'Wscript.Sleep 3000 ' time spent in simulator
> 'objXL.SendKeys "{1B}", True 'Esc key

> i think one of the problems also is the fact that
> i need to send all the keys at once, not individually

> thanks for any help, i appreciate it !



Fri, 18 Feb 2005 13:44:47 GMT  
 SendKeys in Excel 97


Quote:
> I do not think it is possible in a script. To bring this "egg" up you need

to actually click on the chart button. Adding chart or
Quote:
> using the menu will not do. What make it worse, is that you need to hold

simultaneously Ctrl+Shift and left mouse click. AutoIt
Quote:
> has got the mouse-click using application window coordinates but I doubt

it can send key combination at the same time. At best you
Quote:
> could save a spreadsheet with selected range and M97 in focus.

> regards,
> --
> Gurgen Alaverdian
> http://www.gurgensvbstuff.com



Quote:



> > Are you wanting to display the ChartWizard, or automate it?

> > If you want to automate, something like this would do it:

> > Const xlLine = 4

> > Set xl = CreateObject("Excel.Application")
> > set wb = xl.Workbooks.Add
> > Set Sheet = wb.ActiveSheet
> > xl.Visible = True

> > Sheet.Cells(1,2).Value = 20
> > Sheet.Cells(1,3).Value = 25
> > Sheet.Cells(1,4).Value = 30
> > Sheet.Cells(1,5).Value = 35
> > Sheet.Cells(1,6).Value = 30
> > Sheet.Cells(1,7).Value = 25
> > Sheet.Cells(1,8).Value = 20
> > set rng = Sheet.Range("A1").Resize(20,10)
> > set Chart = Sheet.Parent.Charts.Add
> > Chart.ChartWizard rng, xlLine, , , , , _
> >  True, "Year", "Year", "Sales"

> > --
> > Please respond in the newsgroup so everyone may benefit.
> > http://dev.remotenetworktechnology.com



> > You could open wizard via menu: send "Alt+i" then "h"

> > --
> > Gurgen Alaverdian
> > http://www.gurgensvbstuff.com


> > hi all

> > i am trying to click the chart wizard button
> > in Excel 97 with a VBS via sendkeys

> > has anyone else done this this before ?
> > could anyone suggest a method of doing this

> > any help would be gratefully appreciated

> > many thanks

> > Ok, many thanks for that.

> > but to be honest about it, i'm actually trying
> > to open the Flight Simulator in Excel 97

> > this is what i have so far

> > Dim objXL
> > Dim objXLchart
> > Set objXL = WScript.CreateObject("Excel.Application")
> > objXL.Visible = TRUE
> > objXL.WorkBooks.Add
> > 'objXL.SendKeys "{74}", True
> > ' Wscript.Sleep 100
> > objXL.Range("X97:L97").Select
> > Wscript.Sleep 50
> > objXL.SendKeys "{09}", True 'Tab key
> > Wscript.Sleep 50 '
> > objXL.SendKeys "{11}" , True 'Ctrl key
> > objXL.SendKeys "{10}" , True 'Shift key
> > 'objXL.SendKeys "{Charts.Add}" , True ' causes error
> > 'objXL.Charts.Add() ' doesnt work for this project
> > 'Wscript.Sleep 3000 ' time spent in simulator
> > 'objXL.SendKeys "{1B}", True 'Esc key

> > i think one of the problems also is the fact that
> > i need to send all the keys at once, not individually

> > thanks for any help, i appreciate it !

Gurgen

Yes that's exactly it, i didn't realise the mouse coordinates
thing played a part in this.
but i have figured out *how to* send several keys at once.

would some kind of API tool be of any help
in the identification of the chart wizard command_button ?
like the API Spy tool in Visual Studio 6 prof.  ??

thanks



Sat, 19 Feb 2005 01:18:08 GMT  
 SendKeys in Excel 97
Are you willing to go that far for this? (-: Well you can try to play with SendMessage function to send mouse click +shit+ctrl
after you got handle on excel window and figure out the chart button coordinates. Check the PlanetSourceCode.com for examples.

Regards,

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:
> Gurgen

> Yes that's exactly it, i didn't realise the mouse coordinates
> thing played a part in this.
> but i have figured out *how to* send several keys at once.

> would some kind of API tool be of any help
> in the identification of the chart wizard command_button ?
> like the API Spy tool in Visual Studio 6 prof.  ??

> thanks



Sat, 19 Feb 2005 06:42:12 GMT  
 SendKeys in Excel 97
Actually I figured out how to do it in the script. All you have to do is to create another chart button in the menu section and
place in right before the "File" menu. This way when you send "Alt" the new chart button is getting the focus. Now all you need to
do is to send Shift+Ctrl+Enter.
Here is a script:
===========EasterEgg.vbs============
Dim objXL
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.WorkBooks.Add
objXL.Range("X97:L97").Select
Wscript.Sleep 50
objXL.SendKeys "{TAB}", True 'Tab key
Wscript.Sleep 50
objXL.SendKeys "%"
Wscript.Sleep 50
objXL.SendKeys "+^~"
================================

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:

> Are you willing to go that far for this? (-: Well you can try to play with SendMessage function to send mouse click +shit+ctrl
> after you got handle on excel window and figure out the chart button coordinates. Check the PlanetSourceCode.com for examples.

> Regards,

> --
> Gurgen Alaverdian
> http://www.gurgensvbstuff.com

> > Gurgen

> > Yes that's exactly it, i didn't realise the mouse coordinates
> > thing played a part in this.
> > but i have figured out *how to* send several keys at once.

> > would some kind of API tool be of any help
> > in the identification of the chart wizard command_button ?
> > like the API Spy tool in Visual Studio 6 prof.  ??

> > thanks



Sat, 19 Feb 2005 10:14:59 GMT  
 SendKeys in Excel 97
Nice code Gurgen

i need to *tweek* it slightly though because
this pulls down the file menu for me.

you have helped me and i really appreciate that, thank you !!

BTW

i have had much success with this API tool
from:
http://www.exhedra.com/vb/scripts/ShowCode.asp?txtCodeId=29566&lngWId=1

as you gathered, it's from a PSC  mirror site


Quote:
> Actually I figured out how to do it in the script. All you have to do is

to create another chart button in the menu section and
Quote:
> place in right before the "File" menu. This way when you send "Alt" the

new chart button is getting the focus. Now all you need to
Quote:
> do is to send Shift+Ctrl+Enter.
> Here is a script:
> ===========EasterEgg.vbs============
> Dim objXL
> Set objXL = CreateObject("Excel.Application")
> objXL.Visible = True
> objXL.WorkBooks.Add
> objXL.Range("X97:L97").Select
> Wscript.Sleep 50
> objXL.SendKeys "{TAB}", True 'Tab key
> Wscript.Sleep 50
> objXL.SendKeys "%"
> Wscript.Sleep 50
> objXL.SendKeys "+^~"
> ================================

> --
> Gurgen Alaverdian
> http://www.gurgensvbstuff.com



Quote:
> > Are you willing to go that far for this? (-: Well you can try to play

with SendMessage function to send mouse click +shit+ctrl
Quote:
> > after you got handle on excel window and figure out the chart button

coordinates. Check the PlanetSourceCode.com for examples.

- Show quoted text -

Quote:

> > Regards,

> > --
> > Gurgen Alaverdian
> > http://www.gurgensvbstuff.com

> > > Gurgen

> > > Yes that's exactly it, i didn't realise the mouse coordinates
> > > thing played a part in this.
> > > but i have figured out *how to* send several keys at once.

> > > would some kind of API tool be of any help
> > > in the identification of the chart wizard command_button ?
> > > like the API Spy tool in Visual Studio 6 prof.  ??

> > > thanks



Sun, 20 Feb 2005 03:05:27 GMT  
 SendKeys in Excel 97

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:

> Nice code Gurgen

> i need to *tweek* it slightly though because
> this pulls down the file menu for me.

It should not if you'd drag the button to the front of menu i.e. right before the file menu  (-:
Now the real challenge would be to script a "spy hunter" in Excel 2000 though...
Quote:
> you have helped me and i really appreciate that, thank you !!

> BTW

> i have had much success with this API tool
> from:
> http://www.exhedra.com/vb/scripts/ShowCode.asp?txtCodeId=29566&lngWId=1

> as you gathered, it's from a PSC  mirror site



> > Actually I figured out how to do it in the script. All you have to do is
> to create another chart button in the menu section and
> > place in right before the "File" menu. This way when you send "Alt" the
> new chart button is getting the focus. Now all you need to
> > do is to send Shift+Ctrl+Enter.
> > Here is a script:
> > ===========EasterEgg.vbs============
> > Dim objXL
> > Set objXL = CreateObject("Excel.Application")
> > objXL.Visible = True
> > objXL.WorkBooks.Add
> > objXL.Range("X97:L97").Select
> > Wscript.Sleep 50
> > objXL.SendKeys "{TAB}", True 'Tab key
> > Wscript.Sleep 50
> > objXL.SendKeys "%"
> > Wscript.Sleep 50
> > objXL.SendKeys "+^~"
> > ================================

> > --
> > Gurgen Alaverdian
> > http://www.gurgensvbstuff.com


> > > Are you willing to go that far for this? (-: Well you can try to play
> with SendMessage function to send mouse click +shit+ctrl
> > > after you got handle on excel window and figure out the chart button
> coordinates. Check the PlanetSourceCode.com for examples.

> > > Regards,

> > > --
> > > Gurgen Alaverdian
> > > http://www.gurgensvbstuff.com

> > > > Gurgen

> > > > Yes that's exactly it, i didn't realise the mouse coordinates
> > > > thing played a part in this.
> > > > but i have figured out *how to* send several keys at once.

> > > > would some kind of API tool be of any help
> > > > in the identification of the chart wizard command_button ?
> > > > like the API Spy tool in Visual Studio 6 prof.  ??

> > > > thanks



Sun, 20 Feb 2005 03:16:15 GMT  
 SendKeys in Excel 97
Ok, thanks Gurgen

Excel 2000  for me is like winning the Loto, maybe
when i save my pennies, but i have to make do with Excel 97

thanks

David


Quote:

> --
> Gurgen Alaverdian
> http://www.gurgensvbstuff.com



Quote:
> > Nice code Gurgen

> > i need to *tweek* it slightly though because
> > this pulls down the file menu for me.

> It should not if you'd drag the button to the front of menu i.e. right

before the file menu  (-:
Quote:
> Now the real challenge would be to script a "spy hunter" in Excel 2000
though...

> > you have helped me and i really appreciate that, thank you !!

> > BTW

> > i have had much success with this API tool
> > from:
> > http://www.exhedra.com/vb/scripts/ShowCode.asp?txtCodeId=29566&lngWId=1

> > as you gathered, it's from a PSC  mirror site



> > > Actually I figured out how to do it in the script. All you have to do
is
> > to create another chart button in the menu section and
> > > place in right before the "File" menu. This way when you send "Alt"
the
> > new chart button is getting the focus. Now all you need to
> > > do is to send Shift+Ctrl+Enter.
> > > Here is a script:
> > > ===========EasterEgg.vbs============
> > > Dim objXL
> > > Set objXL = CreateObject("Excel.Application")
> > > objXL.Visible = True
> > > objXL.WorkBooks.Add
> > > objXL.Range("X97:L97").Select
> > > Wscript.Sleep 50
> > > objXL.SendKeys "{TAB}", True 'Tab key
> > > Wscript.Sleep 50
> > > objXL.SendKeys "%"
> > > Wscript.Sleep 50
> > > objXL.SendKeys "+^~"
> > > ================================

> > > --
> > > Gurgen Alaverdian
> > > http://www.gurgensvbstuff.com


> > > > Are you willing to go that far for this? (-: Well you can try to
play
> > with SendMessage function to send mouse click +shit+ctrl
> > > > after you got handle on excel window and figure out the chart button
> > coordinates. Check the PlanetSourceCode.com for examples.

> > > > Regards,

> > > > --
> > > > Gurgen Alaverdian
> > > > http://www.gurgensvbstuff.com

> > > > > Gurgen

> > > > > Yes that's exactly it, i didn't realise the mouse coordinates
> > > > > thing played a part in this.
> > > > > but i have figured out *how to* send several keys at once.

> > > > > would some kind of API tool be of any help
> > > > > in the identification of the chart wizard command_button ?
> > > > > like the API Spy tool in Visual Studio 6 prof.  ??

> > > > > thanks



Mon, 21 Feb 2005 02:05:11 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Printing to Eps from Excel 97

2. Excel 97 automation issues/ gotchas??

3. Excel 97 macro problem

4. Starting Excel 97 from a Powerpoint presentation

5. Excel 97 automation issues/ gotchas??

6. Error Handling: cscript, vbscript, excel 97

7. Opening an Excel 97 Workbook from a web page

8. Automatic Paste of Html Table to Excel 97

9. NEEDED: sample VB code for Excel 97 worksheet processing

10. Can Excel 97 get Reference to WScript Objects?

11. Problem with auto_open macro within Excel 97 calling from VB script

12. Importing info from excel 97

 

 
Powered by phpBB® Forum Software