Switching from IE to Chrome: iMacros and vba not performing as expected

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
PeteWithGlasses
Posts: 2
Joined: Mon May 16, 2022 12:29 pm

Switching from IE to Chrome: iMacros and vba not performing as expected

Post by PeteWithGlasses » Mon May 16, 2022 1:16 pm

Please forgive me, first time poster and pretty much everything I know about imacros and vba I've either inherited or had to teach myself so if any of the script is messy then I apologise!

In the business I work for, we use iMacros to automate a lot of the day to day processes (mainly copy/pasting data into a website and submitting as well as page navigation; however IE is about to be removed as support for it is being ended. We've upgraded to the Chrome version, have the Enterprise license etc. but are now experiencing difficulties. I honestly thought it would just involve updating the odd line of code so imacros opened Chrome instead of IE but it doesn't appear that way anymore.

We use it in conjunction with a lot of vba enabled spreadsheets and whilst we've been using IE, everything has been running fine without problems. With the switch to Chrome, we're finding every time a macro is ran from Excel, it will open a new instance of iMacros as well as a new Chrome browser despite both being open at the time and the best of my knowledge, the vba is correct (it doesn't have this behaviour in IE).

I thought I could try and re-record some of the imacros, to see if there was differences but the recorder only logs the first line (which is the url of the page I'm on) and none of the button clicks etc.

We're also experiencing problems where lines of code don't seem to work anymore (like SET !MARKOBJECT NO seems to generate an error that the macro can't ignore even though SET !EVENTIGNORE YES is in place). Again, this worked fine in IE.

Current version of iMacros for Chrome is v12.6 (64 bit) (Version build 10.1.0.1465 I think)
Current Chrome version is 101.0.4951.54 (Official Build) (64-bit)
Current version of Windows 10 (version 21H2 - OS build 19044.1645)

The demo macros work but open a new instance of imacros and chrome browser each time they're ran.

Unfortunately I can't provide a link to the website as you need to be logged in to view (plus it's full of sensitive data).

As mentioned above, many of the imacros have been created by previous employees, been cannibalised from reading up on what others have done or recording and working out how to do things for myself.

This is the vba from one such example:

Code: Select all

    Sub Entdat_ANDY()
  
    Dim s As Integer
    Dim e As Integer
    Dim ans As Integer
    Dim ans2 As Integer
    
   s = 0
   e = 0
   
   'On Error GoTo errhndlr
   
   If MsgBox("Before you click yes to enter data" & vbNewLine & "make sure PP is logged in and" _
    & vbNewLine & "Imacros is open", vbOKCancel, "SHIP TASK") = vbCancel Then
    Exit Sub
   End If
    
   Dim iim1, iret, row, totalrows
   
   Set iim1 = CreateObject("imacros")
   'iret = iim1.iimOpen("-ie", False, 300)
   iret = iim1.iimOpen("-cr", False, 300)

   iret = iim1.iimDisplay("Submitting Data from Excel")
   
   iret = iim1.iimPlay("PP Orders Screen-cr")
     
   totalrows = ActiveSheet.UsedRange.Rows.Count
   For row = 7 To totalrows
     If Cells(row, 1).Value <> "" Then
      'Set the variables
      iret = iim1.iimSet("Ponum", Cells(row, 2).Value)
      iret = iim1.iimSet("Startdate", Cells(row, 3).Value)
      iret = iim1.iimSet("Enddate", Cells(row, 4).Value)
      iret = iim1.iimSet("Line1", Cells(3, 7).Value)
      'Set the display
      iret = iim1.iimDisplay("Row# " + CStr(row))
      'Run the macro
      iret = iim1.iimPlay("PP Attachment Ship-cr") <---this stage always errors then moves onto Attachment Submit below
      'On error run the Imacro error dump for the row
      iret = iim1.iimPlay("PP Attachment Submit-cr") <---this works fine
         
         
      'iret = iim1.iimPlay("PP Job Detail Return to Enter-cr")
      iret = iim1.iimPlay("Orders tab")
      
      iret = iim1.iimSet("OtherStartDate", Cells(2, 7).Value)
      
      iret = iim1.iimSet("Ponum", Cells(row, 2).Value)
      iret = iim1.iimSet("StartDate", Cells(row, 6).Value)
      iret = iim1.iimSet("Pattern", Cells(row, 5).Value)
      
      
      iret = iim1.iimPlay("PP Job Details-cr")
      
This is iim1.iimPlay("PP Orders Screen-cr"):

Code: Select all

VERSION BUILD=9002379
TAB T=1
'TAB CLOSEALLOTHERS
URL GOTO=https:// (web address removed)
TAG POS=1 TYPE=DIV ATTR=TXT:DDD<SP>iSupplier<SP>Portal<SP>Administrator<SP>(Create<SP>and<SP>View)
TAG POS=1 TYPE=DIV ATTR=TXT:DDD<SP>iSupplier<SP>Portal<SP>Administrator<SP>(Create<SP>and<SP>View)
TAG POS=1 TYPE=A ATTR=TXT:Orders
This is the iim1.iimPlay("PP Attachment Ship-cr"):

Code: Select all

VERSION BUILD=9002379
SET !ERRORIGNORE YES
SET !MARKOBJECT NO

TAG POS=1 TYPE=A FORM=NAME:DefaultFormName ATTR=TXT:Shipments
TAG POS=1 TYPE=A ATTR=TXT:Create<SP>Advance<SP>Shipment<SP>Notices
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:Value_1 CONTENT={{Ponum}}
TAG POS=1 TYPE=BUTTON:SUBMIT FORM=NAME:DefaultFormName ATTR=TXT:Go
TAG POS=1 TYPE=SPAN FORM=NAME:DefaultFormName ATTR=TXT:{{Line1}}
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:DefaultFormName ATTR=NAME:ShipmentTable:selected:0 CONTENT=YES
TAG POS=1 TYPE=BUTTON:SUBMIT FORM=NAME:DefaultFormName ATTR=ID:PosAsnAddToCart
TAG POS=1 TYPE=A FORM=NAME:DefaultFormName ATTR=TXT:Shipment<SP>Header
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:ShipNumEntry CONTENT={{Ponum}}-1
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:ShipDateEntry CONTENT={{Startdate}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:ExpRcptDateEntry CONTENT={{Enddate}
iMacros window pops up with an error about the !MARKOBJECT command before skipping completely.

Hopefully I haven't missed anything; any help would be greatly appreciated!

Pete.
Last edited by PeteWithGlasses on Tue May 17, 2022 11:16 am, edited 1 time in total.
chivracq
Posts: 10231
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Help with Chrome version of iMacros

Post by chivracq » Mon May 16, 2022 4:15 pm

PeteWithGlasses wrote:
Mon May 16, 2022 1:16 pm
Please forgive me, first time poster and pretty much everything I know about imacros and vba I've either inherited or had to teach myself so if any of the script is messy then I apologise!

In the business I work for, we use iMacros to automate a lot of the day to day processes (mainly copy/pasting data into a website and submitting as well as page navigation; however IE is about to be removed as support for it is being ended. We've upgraded to the Chrome version, have the Enterprise license etc. but are now experiencing difficulties. I honestly thought it would just involve updating the odd line of code so imacros opened Chrome instead of IE but it doesn't appear that way anymore.

We use it in conjunction with a lot of vba enabled spreadsheets and whilst we've been using IE, everything has been running fine without problems. With the switch to Chrome, we're finding every time a macro is ran from Excel, it will open a new instance of iMacros as well as a new Chrome browser despite both being open at the time and the best of my knowledge, the vba is correct (it doesn't have this behaviour in IE).

I thought I could try and re-record some of the imacros, to see if there was differences but the recorder only logs the first line (which is the url of the page I'm on) and none of the button clicks etc.

We're also experiencing problems where lines of code don't seem to work anymore (like SET !MARKOBJECT NO seems to generate an error that the macro can't ignore even though SET !EVENTIGNORE YES is in place). Again, this worked fine in IE.

Code: Select all

Current version of iMacros for Chrome is v12.6 (64 bit) (Version build 1011?)
Current Chrome version is 101.0.4951.54 (Official Build) (64-bit)
Current version of Windows 10 (version 21H2 - OS build 19044.1645)
The demo macros work but open a new instance of imacros and chrome browser each time they're ran.

Unfortunately I can't provide a link to the website as you need to be logged in to view (plus it's full of sensitive data).

As mentioned above, many of the imacros have been created by previous employees, been cannibalised from reading up on what others have done or recording and working out how to do things for myself.

This is the vba from one such example:

Code: Select all

    Sub Entdat_ANDY()
  
    Dim s As Integer
    Dim e As Integer
    Dim ans As Integer
    Dim ans2 As Integer
    
   s = 0
   e = 0
   
   'On Error GoTo errhndlr
   
   If MsgBox("Before you click yes to enter data" & vbNewLine & "make sure PP is logged in and" _
    & vbNewLine & "Imacros is open", vbOKCancel, "SHIP TASK") = vbCancel Then
    Exit Sub
   End If
    
   Dim iim1, iret, row, totalrows
   
   Set iim1 = CreateObject("imacros")
   'iret = iim1.iimOpen("-ie", False, 300)
   iret = iim1.iimOpen("-cr", False, 300)

   iret = iim1.iimDisplay("Submitting Data from Excel")
   
   iret = iim1.iimPlay("PP Orders Screen-cr")
     
   totalrows = ActiveSheet.UsedRange.Rows.Count
   For row = 7 To totalrows
     If Cells(row, 1).Value <> "" Then
      'Set the variables
      iret = iim1.iimSet("Ponum", Cells(row, 2).Value)
      iret = iim1.iimSet("Startdate", Cells(row, 3).Value)
      iret = iim1.iimSet("Enddate", Cells(row, 4).Value)
      iret = iim1.iimSet("Line1", Cells(3, 7).Value)
      'Set the display
      iret = iim1.iimDisplay("Row# " + CStr(row))
      'Run the macro
      iret = iim1.iimPlay("PP Attachment Ship-cr") <---this stage always errors then moves onto Attachment Submit below
      'On error run the Imacro error dump for the row
      iret = iim1.iimPlay("PP Attachment Submit-cr") <---this works fine
         
         
      'iret = iim1.iimPlay("PP Job Detail Return to Enter-cr")
      iret = iim1.iimPlay("Orders tab")
      
      iret = iim1.iimSet("OtherStartDate", Cells(2, 7).Value)
      
      iret = iim1.iimSet("Ponum", Cells(row, 2).Value)
      iret = iim1.iimSet("StartDate", Cells(row, 6).Value)
      iret = iim1.iimSet("Pattern", Cells(row, 5).Value)
      
      
      iret = iim1.iimPlay("PP Job Details-cr")
      
This is iim1.iimPlay("PP Orders Screen-cr"):

Code: Select all

VERSION BUILD=9002379
TAB T=1
'TAB CLOSEALLOTHERS
URL GOTO=https:// (web address removed)
TAG POS=1 TYPE=DIV ATTR=TXT:DDD<SP>iSupplier<SP>Portal<SP>Administrator<SP>(Create<SP>and<SP>View)
TAG POS=1 TYPE=DIV ATTR=TXT:DDD<SP>iSupplier<SP>Portal<SP>Administrator<SP>(Create<SP>and<SP>View)
TAG POS=1 TYPE=A ATTR=TXT:Orders
This is the iim1.iimPlay("PP Attachment Ship-cr"):

Code: Select all

VERSION BUILD=9002379
SET !ERRORIGNORE YES
SET !MARKOBJECT NO

TAG POS=1 TYPE=A FORM=NAME:DefaultFormName ATTR=TXT:Shipments
TAG POS=1 TYPE=A ATTR=TXT:Create<SP>Advance<SP>Shipment<SP>Notices
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:Value_1 CONTENT={{Ponum}}
TAG POS=1 TYPE=BUTTON:SUBMIT FORM=NAME:DefaultFormName ATTR=TXT:Go
TAG POS=1 TYPE=SPAN FORM=NAME:DefaultFormName ATTR=TXT:{{Line1}}
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:DefaultFormName ATTR=NAME:ShipmentTable:selected:0 CONTENT=YES
TAG POS=1 TYPE=BUTTON:SUBMIT FORM=NAME:DefaultFormName ATTR=ID:PosAsnAddToCart
TAG POS=1 TYPE=A FORM=NAME:DefaultFormName ATTR=TXT:Shipment<SP>Header
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:ShipNumEntry CONTENT={{Ponum}}-1
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:ShipDateEntry CONTENT={{Startdate}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DefaultFormName ATTR=NAME:ExpRcptDateEntry CONTENT={{Enddate}
iMacros window pops up with an error about the !MARKOBJECT command before skipping completely.

Hopefully I haven't missed anything; any help would be greatly appreciated!

Pete.

:arrow: Euuuuhhh, could you give a more Descriptive Title to your Thread (for me to read)...? :idea:

"Help with Chrome version of iMacros" is completely vague, I have no idea from only your Thread Title what your Thread is about, "Help" + "iMacros" are completely useless for sure, "Chrome" maybe but that Term would also apply to 100% of all Threads opened in the 'iMacros for CR' Sub-Forum..., ... which probably was not the "correct" Sub-Forum to open your Thread, I see some "Dim" + "iimXXX()" Commands, typical for a '.vbs'/'.vba' Script, I'll probably have to move your Thread to the 'SI' (= 'Scripting Interface') Sub-Forum... :?
(No need to duplicate, I'll move the Thread if necessary, once I'll have read it...)

FCI mentioned, perfect, although, hum-hum..., '.vbs'/'.vba' Script, we'll need the 'SI' Version, not (clearly) mentioned, the closest is:

Code: Select all

Current version of iMacros for Chrome is v12.6 (64 bit) (Version build 1011?)
=> "Version build 1011" =>v10.1.1 (for CR) is indeed a (valid (and current)) Version of iMacros for CR, working indeed in CR101. 8)
And "v12.6" would then be a (valid) Version for iMB + 'SI', which is indeed compatible with v10.1.x for CR. 8)

Then hum, my "scanning" Eye caught some "funny" Command in your OP: `!EVENTIGNORE`...! :o :?
Euh..., sounds nice, but I don't know this one...!?, or did you discover some Easter Egg in the Code...!? :twisted: => `!ERRORIGNORE` maybe...? :?
(No "big deal" about this one though, I'll probably have more "Remarks" after reading your full OP, but I first "want" a Descriptive Thread Title before putting any "Effort" in your Thread... (And Compliment for "the rest" though, Quality looks very good to me...) :wink: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
PeteWithGlasses
Posts: 2
Joined: Mon May 16, 2022 12:29 pm

Re: Switching from IE to Chrome: iMacros and vba not performing as expected

Post by PeteWithGlasses » Tue May 17, 2022 11:25 am

Hi Chivracq,

Thanks for taking the time to respond.

I've updated the thread title to be a lot less vague!

The imacros version we're running for Chrome is v12.6 (64 bit) (Version build 10.1.0.1465 I think); I've updated my main post with this information.

I do have a couple of updates; slowing iMacros to medium speed has helped a lot; the site we're using the macros on isn't the quickest and a bit slow in places; slowing the macro speed has improved performance and for parts where it doesn't, I've added some 3 second waits. I've also found the Chrome version doesn't like the command SET !MARKOBJECT as it tends to error at this point when running so these have been removed.

To clarify on a new Chrome/imacros instance opening each time a macro is run; this doesn't happen the very first time a macro is run, it only happens each time after that. The recording function sort of works? With the multiple instances of browser/imacros open, providing I'm using the corresponding imacro to browser to record then it will start recording for a couple of lines then give up 9stops recording any new inputs).

Any advice or insight is greatly appreciated; as I mentioned previously I'm very much teaching myself this on the fly and having inherited 'old' code from other users who were equally clueless, I'm slowly working out what works, what doesn't and what is redundant!

Pete.
Tom, Tech Support
Posts: 3811
Joined: Mon May 31, 2010 4:59 pm

Re: Switching from IE to Chrome: iMacros and vba not performing as expected

Post by Tom, Tech Support » Wed May 25, 2022 11:59 am

Hi Pete,

Sorry I'm late to the party here!
PeteWithGlasses wrote:
Tue May 17, 2022 11:25 am
To clarify on a new Chrome/imacros instance opening each time a macro is run; this doesn't happen the very first time a macro is run, it only happens each time after that.
Yes, this is a known issue with the current version of the iMacros scripting interface and was documented in the release notes for iMacros-CR 10.1.0:
  • Fixed: iimOpen("-cr", False) can only attach to an existing browser if it has not yet played any macro*
* Requires related updates to File Access module for iMacros Extensions as well as Enterprise scripting interface (API)

So, as long as you download and apply this patch, this issue will be resolved.

PeteWithGlasses wrote:
Tue May 17, 2022 11:25 am
I've also found the Chrome version doesn't like the command SET !MARKOBJECT as it tends to error at this point when running so these have been removed.
Not all macro commands are supported in all browsers. Consult the Command Reference page in the iMacros wiki and heed the browser icons next to each command/variable name. These indicate in which browser(s) the command or variable is supported.


As far as recording issues, if you find that some things are not recording using the normal, conventional (TAG) recording mode, you may need to try recording them with the Event recording mode (Click the Manage tab on the iMacros sidebar and then click the Settings button). More information about the EVENT command can be found in the wiki.
Regards,

Tom, iMacros Support
Post Reply