Credo di aver bisogno di chiamare un metodo javascript invece di provare a far scattare i pulsanti. Ho provato i seguenti esempi e penso che il mio problema è che non so quali parti del codice dovrei usare .. Click button or execute JavaScript function with VBA e questo http://www.vbaexpress.com/forum/showthread.php?9690-Solved-call-a-javascript-function e http://www.vbforums.com/showthread.php?650771-RESOLVED-How-to-Call-a-JavaScript-function-From-Visual-Basic-6-WITH-wanted-parametersCome trovare e chiamare il metodo javascript da vba
non riesco a postare un link, perché richiede un account di accesso per accedervi ... Per favore fatemi sapere se avete bisogno di un campione più ampio del codice per dare un senso alla mia domanda.
credo di aver bisogno di una funzione che fa riferimento a "Esporta come CSV", ma io non sono sicuro di quale funzione di chiamare e quali parti della funzione da includere nella chiamata ... Quello che segue è da 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}
Questo campione successivo è da 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'};
ho provato queste opzioni nel mio script VBA ..
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
Sto cercando di eseguire questo da VBA in modo da non potrei uso var ...
Dim getFunction = "get:function (_shouldhaverowaction(this.export,C)),(b.getPlugin(chr(34)printplugin chr(34)))"
Dim exportNow
eval ("exportNow = new" + getFunction + ";")
E ho anche provato
Call objIE.HTMLDocument.eval("get:function (_shouldhaverowaction(this.export,C)),(b.getPlugin(chr(34) printplugin chr(34)))", "JavaScript")
ho ottenuto "L'oggetto doesnt supporta questa proprietà o metodo" errore quando Ho provato a farlo funzionare.
Qualsiasi suggerimento sarebbe davvero eccezionale.
Mi sono appena imbattuto in un'altra funzione che potrebbe essere quella che desidero ma non so ancora quale parte dovrei usare per chiamare. Ho provato a richiamare appena _getExportItems: function() ma ottengo tempo di errore non può completare l'operazione a causa dell'errore 80020101 (errore durante la valutazione 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})}
'' 'execScript''' non è più supportato. A partire da Internet Explorer 11, utilizzare [eval] (https://msdn.microsoft.com/en-us/library/ms536420%28v=vs.85%29.aspx). – dee
Ciao Dee Ho seguito il tuo link e ho provato queste due cose .. Sto cercando di eseguire questo da VBA quindi non potrei usare var ... 'Dim getFunction = "get: function (_shouldhaverowaction (this.export, C)), (b.getPlugin (chr (34) printplugin chr (34))) " 'Dim exportNow' eval (" exportNow = new "+ getFunction +"; ") ** E HO ANCHE PROVATO ** Chiama objIE.HTMLDocument.eval ("get: function (_shouldhaverowaction (this.export, C)), (b.getPlugin (chr (34) printplugin chr (34)))", "JavaScript") I GOT L'OGGETTO NON SUPERA QUESTO IMMOBILE O ERRORE DEL METODO. – Kdunc2015