I believe I need to call a javascript method instead of trying to fire buttons. I have tried the following examples and I think my problem is that I don't know which parts of the code I should use..Click button or execute JavaScript function with VBA and this http://www.vbaexpress.com/forum/showthread.php?9690-Solved-call-a-javascript-function and http://www.vbforums.com/showthread.php?650771-RESOLVED-How-to-Call-a-JavaScript-function-From-Visual-Basic-6-WITH-wanted-parameters
I can't post a link because it requires a login to access it... Please let me know if you need a larger sample of the code to make sense of my question.
I believe I need a function that references "Export as CSV" but I am not sure which function to call and which parts of function to include in the call... The following is from catalog.js
function()
{var a=window.Ext4||window.Ext;a.define ("Rally.alm.ui.page.plugins.PageToolFactory",{singleton:true,mixins: {messageable:Rally.Messageable},PRINT:"PRINT",IMPORT:"IMPORT",EXPORT:"EXPORT",ge t:function(c,b)
{var d=[];
if(this._shouldHaveRowAction(this.PRINT,c))
{
if(b.getPlugin("printplugin"))
{
d.push({text:"Print...",handler:b.getPlugin("printplugin").print,cls:"page- tools",scope:b.getPlugin("printplugin"),addInteractionClass:true})}}
if(this._shouldHaveRowAction(this.IMPORT,c))
{
if(b.getPlugin("printplugin"))
{
d.push({text:"Import User Stories...",handler:a.emptyFn})}}
if(this._shouldHaveRowAction(this.EXPORT,c))
{
if(b.getPlugin("printplugin"))
{
d.push({text:"Export as CSV",handler:a.emptyFn})}} return d}
This next sample is from yui.js...
(function()
{
RALLY.ui.menu.AvailablePageTools=Ext.extend(Object, {constructor:function()
{
this.PRINT={text:'Print...',slug:'print'};
this.EMAIL={text:'Email...',slug:'email'};
this.SAVE={text:'Save...',slug:'save'};
this.CSV_IMPORT={text:'Import User Stories...',slug:'csvimport'};
this.CSV_IMPORT_PORTFOLIO_ITEM={text:'Import Portfolio Items...',slug:'csvimport'};
this.CSV_EXPORT={text:'Export as CSV',slug:'csvexport'};
this.PDF_EXPORT={text:'Export as PDF',slug:'pdfexport'};
I have tried these options in my vba script..
Dim objIE As SHDocVw.InternetExplorer 'microsoft internet controls (shdocvw.dll)
Dim htmlDoc As MSHTML.HTMLDocument 'Microsoft HTML Object Library
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlColl As MSHTML.IHTMLElementCollection
Dim CurrentWindow As HTMLWindowProxy
'Set objIE = Nothing
Set objIE = New SHDocVw.InternetExplorer
ThisWorkbook.Worksheets("Sheet1").Activate
With objIE
.navigate "website"
.Visible = 1
Do While .readyState <> 4: DoEvents: Loop
Application.Wait (Now + TimeValue("0:00:02"))
Set htmlDoc = .document
objIE.document.all.Item
'Set CurrentWindow = objIE.htmlDoc.parentWindow
'no error no export
'Call objIE.document.parentWindow.execScript("_exportHandler:Function()", "JavaScript")
'no error no export
'Call objIE.document.parentWindow.execScript("_getExportItems:Function()", "JavaScript")
'RUN TIME ERROR could not complete the operation due to error 80020101 (error while evaluating js)
'Call objIE.document.parentWindow.execScript("_a.define()", "JavaScript")
'run time error the object invoked has disconnected from its clients,
'RUN TIME ERROR could not complete the operation due to error 80020101 (error while evaluating js)
'Call objIE.document.parentWindow.execScript("_b.push()", "JavaScript")
'run time error the object invoked has disconnected from its clients,
'RUN TIME ERROR could not complete the operation due to error 80020101 (error while evaluating js)
'Call objIE.document.parentWindow.execScript("handler:function(){window.location=Rally.ui.grid.GridExport.buildCsvExportUrl(this.gridboard.getGridOrBoard())}", "JavaScript")
'Call objIE.document.parentWindow.execScript("b.push()", "JavaScript")
'Call objIE.document.parentWindow.execScript("c.push()", "JavaScript")
'RUN TIME ERROR could not complete the operation due to error 80020101 (error while evaluating js)
'Call objIE.document.parentWindow.execScript("this.CSV_Export()", "JavaScript")
'error the remote server machine does not exist or is unavailable
'Call objIE.document.parentWindow.execScript("constructor:function()", "JavaScript")
'Call objIE.document.parentWindow.execScript("constructor:function()", "JavaScript")
'object
Call CurrentWindow.execScript("d.push({text:CHR(34)Export as CSV CHR(34),handler:a.emptyFn})")
'ofile.SaveAs scrapeRally:=ofile.Name
'ofile.Close savechanges:=False
'objIE.Quit
Set objIE = Nothing
End With
End Sub
I am trying to run this from VBA so I couldnt use var...
Dim getFunction = "get:function (_shouldhaverowaction(this.export,C)),(b.getPlugin(chr(34)printplugin chr(34)))"
Dim exportNow
eval ("exportNow = new" + getFunction + ";")
And I also tried
Call objIE.HTMLDocument.eval("get:function (_shouldhaverowaction(this.export,C)),(b.getPlugin( chr(34) printplugin chr(34)))", "JavaScript")
I got "The object doesnt support this property or method" error when I tried to run it.
Any suggestions would be really great.
I just came across another function that could be the one I want but I still don't know what part of it I should use to call. I tried to call just _getExportItems:function() but I get RUN TIME ERROR could not complete the operation due to error 80020101 (error while evaluating js)
_getExportItems:function(){
var b=[];
if(this.enableCsvExport){
b.push({
text:"Export to CSV...",
handler:function(){
window.location=Rally.ui.grid.GridExport.buildCsvExportUrl (this.gridboard.getGridOrBoard())},scope:this})}