Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to read a txt file form a macro, but it's not working. The syntax seems to be right, and I have set the "requested module security" to "system access" and "Current Local Security" to "allow system access". And of course, I have made sure that the file is there and there is no a permissions problem. The code is really simple:
SUB mReadDelimitedFile()
Set objFSO = CreateObject("Scripting.FileSystemObject")
msgbox 2
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", ForReading)
msgbox 3
END SUB
well... it just doesn't execute msgbox 3.
Any idea?
Thank you.
Hi Mate,
There is an issue using the constant for "ForReading in OpenTextFile method. You need to use the values "1" instead of the constant. So replace "ForReading" with "1". Here is the updated script:
SUB mReadDelimitedFile()
Set objFSO = CreateObject("Scripting.FileSystemObject")
msgbox 2
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", 1)
msgbox 3
END SUB
Thanks,
DV
www.QlikShare.com
Hi,
I guess it does execute "2" but doesn't execute "3". Do you mind posting the sample app?
Thanks,
DV
www.QlikShare.com
Are you trying to run it under ajax client ?
If so, macros struggle
Hi Deepak,
That's right. It doesn't reach 3.
I just attached an example.
Thank you
Joaquin
Hi Graeme,
No, that's still desktop!
Thanks
Sorry - I replied before you attached the qvw
Hi Mate,
There is an issue using the constant for "ForReading in OpenTextFile method. You need to use the values "1" instead of the constant. So replace "ForReading" with "1". Here is the updated script:
SUB mReadDelimitedFile()
Set objFSO = CreateObject("Scripting.FileSystemObject")
msgbox 2
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", 1)
msgbox 3
END SUB
Thanks,
DV
www.QlikShare.com
Excellent!
Thank you