Search code examples
vbscriptasp-classicxlsxfilesystemobject

How to read an Excel file from VBScript?


I am trying to read an Excel file in VBScript, but in the file.Readline I am getting strange characters. Do you have any idea how you could get the value of the cells correctly? Without Excel libraries.

Dim fso,file
Set fso  = Server.CreateObject("Scripting.FileSystemObject")
Set dict = CreateObject("Scripting.Dictionary")        
Set file = fso.OpenTextFile ("C:\myFile.xlsx",1)
row = 0
Do Until file.AtEndOfStream
    line = file.Readline
    dict.Add row, line
    row = row + 1
Loop
file.Close

Solution

  • I have solved my problem using the extension .CSV, since this allows me to read the information as a .txt in which each column is separated with commas by default, so my code works normally.