VBA to write into .IIM

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
Sergiusz
Posts: 3
Joined: Thu Sep 04, 2014 6:43 pm

VBA to write into .IIM

Post by Sergiusz » Thu Sep 04, 2014 7:20 pm

Greetings!
Tried to find something similar but i missed. I faced strange problem with writing to IIM file like simple TXT.
I use Excel VBA to generate script depending of cells values and then load it directly to IIM file. It works good on my home PC but it doesn't on my work.
In this PC Imacros doesn't see any code in IIM file written, like it is empty, but it can be viewed on Notepad etc.
When I open in Notepad the macro written by Imacros, it looks like just one line, and has normal view in Notepad++.
Here the simple code to run in VBA Excel

Code: Select all

Sub imacros()
Dim imsi As String
macrofile = "C:\Users\sergiusz\Documents\iMacros\Macros\new.iim"
Open macrofile For Output As #1
Print #1, "VERSION BUILD=8820413 RECORDER=FX" 
Close #1
End Sub
I use Windows 7 and MS Office 2010 Professional Plus on my work PC and Windows Xp+Office 2010 on the home PC.
I suspect some hiiden symbols is in the roots of problem. Any ideas to help me? Thx.
Attachments
Capture.PNG
Capture.PNG (5.64 KiB) Viewed 8064 times
chivracq
Posts: 8525
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: VBA to write into .IIM

Post by chivracq » Sat Sep 06, 2014 6:02 pm

Open your Script once using the iMacros Editor and resave it, I would suggest, or open it in WordPad and resave it to open it then in Notepad to check that the Line Breaks have been correctly converted (and resave it eventually (in Notepad) using UTF-8 Encoding...).
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Sergiusz
Posts: 3
Joined: Thu Sep 04, 2014 6:43 pm

Re: VBA to write into .IIM

Post by Sergiusz » Sun Sep 07, 2014 4:07 pm

Thanks a lot with UTF-8 idea! :idea:
Now it works with another method of file writing. Something like this

Code: Select all

Sub Save2File()
sText = "URL GOTO=http://google.com"
sFile = "C:\Users\sergiusz\Documents\iMacros\macros\new.iim"
    Dim oStream
    Set oStream = CreateObject("ADODB.Stream")
    With oStream
        .Open
        .Charset = "utf-8"
        .WriteText sText
        .SaveToFile sFile, 2
    End With
    Set oStream = Nothing
End Sub
chivracq
Posts: 8525
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: VBA to write into .IIM

Post by chivracq » Sun Sep 07, 2014 7:14 pm

Sergiusz wrote:Thanks a lot with UTF-8 idea! :idea:
Now it works with another method of file writing. Something like this

Code: Select all

Sub Save2File()
sText = "URL GOTO=http://google.com"
sFile = "C:\Users\sergiusz\Documents\iMacros\macros\new.iim"
    Dim oStream
    Set oStream = CreateObject("ADODB.Stream")
    With oStream
        .Open
        .Charset = "utf-8"
        .WriteText sText
        .SaveToFile sFile, 2
    End With
    Set oStream = Nothing
End Sub
Good...! And thanks for sharing, that might help some other Users one day...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Sergiusz
Posts: 3
Joined: Thu Sep 04, 2014 6:43 pm

Re: VBA to write into .IIM

Post by Sergiusz » Mon Sep 08, 2014 2:39 pm

By the way, one more thing i'd like to add is execution of written script after its generation:

Code: Select all

Sub Save2File()
.....
Shell "C:\Program Files\Mozilla Firefox\firefox.exe imacros://run/?m=new.iim"
End sub 
:wink:
hnoor0033
Posts: 1
Joined: Wed Feb 03, 2016 5:24 am

Re: VBA to write into .IIM

Post by hnoor0033 » Wed Feb 03, 2016 5:34 am

it can be viewed on Notepad etc.
When I open in Notepad the macro written by Imacros,
NOOR
Post Reply