WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: George Vagenas on December 20, 2014, 11:20:55 PM

Title: COM: Access denied
Post by: George Vagenas on December 20, 2014, 11:20:55 PM
I'm getting this error but I have no idea how to fix it.  My script is trying to access an IE document item.
Code (winbatch) Select
   prqDoc = prqIE.Document                                            ; Safety refresh.
   prqAll = prqDoc.All

   prqObj = prqAll.item(prqHdrNum)

The value in prqHdrNum is 100 and as usual with IE this used to work fine with version 8 but now throws an error in IE 11.
Title: Re: COM: Access denied
Post by: ....IFICantBYTE on December 21, 2014, 04:09:34 AM
George,
Document.All no longer exists in IE11.
see: http://msdn.microsoft.com/en-us/library/ie/ms537434(v=vs.85).aspx
(http://msdn.microsoft.com/en-us/library/ie/ms537434(v=vs.85).aspx)
http://msdn.microsoft.com/en-us/library/ie/bg182625(v=vs.85).aspx
(http://msdn.microsoft.com/en-us/library/ie/bg182625(v=vs.85).aspx)
Title: Re: COM: Access denied
Post by: George Vagenas on December 22, 2014, 10:52:18 PM
Deprecated but still supported is my understanding but its a moot point as I have revised my script to not use document.all. 
Which has led me to another problem, these lines work fine when stepping through the script in Studio:
Code (winbatch) Select
      prqType = prqDoc.getElementById("acctnum")
      if prqType==''
         pause('Error! in CUrAcct.wbt::GetTxs', 'Line #1056' : @lf : 'prqType = prqDoc.getElementById("acctnum")': @tab:'failed.')
         exit
      endif
      prqType.value = gAcctNo
     
      objEvent = prqDoc.createEvent("HTMLEvents")
      i = prqDoc.GetElementById("Continue")
      If objEvent == ""
         i.click
      Else
         objEvent.initEvent("click", @true, @true)
         i.dispatchEvent(objEvent)
      EndIf
     
; pause(`DEBUG PAUSE`, strCat(`gPwd = `, gPwd))   ;***DEBUG LINE***
breakpoint     
      prqType       = prqDoc.getElementById("pac")
      prqType.value = gPwd

I defined prqIE earlier in the script:
Code (winbatch) Select
   ; Script requires access to these MSIE objects.
   prqDoc = prqIE.Document

But when I run the script normally I get this error:
QuotewErrFile = GetTxs
wError = 3131
wErrStr = OleExecute: Not a valid OLE object. Period may have been used in place of a comma.
wErrLine = prqType.value = gPwd
wErrOffset = 970
wErrAssign =
Stumped as to why the last two lines now throw an error.
Title: Re: COM: Access denied
Post by: td on December 23, 2014, 08:09:08 AM
Since scripts run much more slowly in the debugger, one possibility is a timing issue.
Title: Re: COM: Access denied
Post by: George Vagenas on December 23, 2014, 03:01:32 PM
Yes, thanks! Silly me, I should have thought of that.  A liberal sprinkling of:
Code (winbatch) Select
   ieChk = IEWait4Page(prqIE)
fixed the problem.
Title: Re: COM: Access denied
Post by: DAG_P6 on December 25, 2014, 12:25:39 AM
Quote from: George Vagenas on December 23, 2014, 03:01:32 PM
Yes, thanks! Silly me, I should have thought of that.  A liberal sprinkling of:
Code (winbatch) Select
   ieChk = IEWait4Page(prqIE)
fixed the problem.

That's why Microsoft put DoEvents into every version of its Basic languages for Windows. Surely, C# has an analogue, although I haven't found or needed it, since the vast majority of the C# code that I've written to date is class libraries that manipulate data and console programs.

Write 100 times the following sentence. Most things in Windows are event driven. That includes Web browsers and most application windows.