AutoHotkey Community

It is currently May 26th, 2012, 2:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: January 28th, 2009, 11:20 pm 
Offline

Joined: January 28th, 2009, 10:53 pm
Posts: 6
Location: MN, USA
I have spent hours looking into all possible ways to get this desired result:

have an autohotkey script change the maximum scale of a chart in an open excel document. i would really prefer to not resort to screen clicks, so i am trying to use ws4ahk.ahk, which allows VBscript to be inserted into AHK. my problem is that i dont know VB at all.

I used excel's built in macro recorder to get this code, the code i am trying to implement in AHK:

Code:
    Set oExcel = GetObject(, "Excel.Application")
    Set oActiveSheet = oExcel.ActiveSheet
    Set oActiveChart = oActiveSheet.ChartObjects("Chart 1")       
    oActiveChart.Activate
    ActiveChart.Axes(xlValue).MaximumScale = 40


This code works, but it is VBA, not VB, and apparently that makes a difference for external scripts. I tried plugging this code directly into the general ws4ahk format:

Code:
#include ws4ahk.ahk
WS_Initialize()
WS_Exec("Set oExcel       = GetObject(,""Excel.Application"")")
WS_Exec("Set oActiveSheet    = oExcel.ActiveWorkbook.Sheets(""tab"")")
WS_Exec("Set oActiveChart = oActiveSheet.ChartObjects(""Chart 1"")")
WS_Exec("oActiveChart.Activate")
WS_Exec("ActiveChart.Axes(xlValue).MaximumScale = 40")
WS_Uninitialize()



this produces an error:
Quote:
Object required: 'ActiveChart'


so then i try to change
Code:
WS_Exec("ActiveChart.Axes(xlValue).MaximumScale = 40")
to
Code:
WS_Exec("[b]o[/b]ActiveChart.Axes(xlValue).MaximumScale = 40")
, and that gives me
Quote:
Object doesn't support this property or method: 'oActive.Axes'


Is this a simple fix? i have been searching for a method of converting VBA to VB to no avail. please help

_________________
-AJ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 1:58 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
http://www.autohotkey.com/forum/viewtop ... 313#241313
i dont believe VBA is usable via ws4ahk

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 2:01 am 
Offline

Joined: January 29th, 2009, 1:03 am
Posts: 41
Location: Australia
Sorry to change the subject but whats ws4ahk.ahk?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 8:20 pm 
Offline

Joined: January 28th, 2009, 10:53 pm
Posts: 6
Location: MN, USA
@tank: you are correct that ws4ahk doesn't support VBA. i am wondering if it is an easy conversion to get this small chunk of code into VBS format? i know there are some differences between VBA and VBS but i am hopeful that it is a small change to get this to work. i looked at your excel library, it looks easy to use :) any chance you might expand it with a few chart functions? ;-)

@Reynoldz: ws4ahk.ahk is a handy library of functions that let you use javascript and VBscript in AHK.

_________________
-AJ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: G. Sperotto, Google [Bot], patgenn123 and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group