Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

read the input of a .txt file into a variable in my vba macro script

Hi @All,

i want to read the input of a .txt file into a variable in my vba macro script.

In line 2 the fso Object is empty ? I don't know why ? So the rest of my script can' work, because i need the fso Object

  1. fso = CreateObject("Scripting.FileSystemObject")
  2. 'msgbox ("FSO: " & fso)
  3. 'dateipfad = "path_and_name.txt"
  4. 'fsoFile = fso.opentextfile(dateipfad, fsoForReading)
  5. 'inhalt = Split(fsoFile.ReadAll, vbCr)
  6. 'inhalt = fsoFile.ReadAll
  7. 'msgBox(inhalt)
  8. 'fsoFile.Close
  9. 'fsoFile = Nothing
10 Replies
Not applicable
Author

Ok thanks, i have the solution.

So I didn't knew that there are a difference between VBA and VBScript.

Like Mr. Zeeman explains, the QlikView Macro only supports VBScript.

So in the past i had VBA Commands in my code, and so it doesn't function.

Here my solution

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.txt", ForReading)

Do Until objFile.AtEndOfStream

    strSearchString = objFile.ReadLine

Loop

objFile.Close