ok so I have some code in a vbs file, where basically I want to open a CSV file. Perform some changes (I can work that out later) and then save it as an xls. The code works flawlessly when run with a fully qualified file path. However I need the file path to be relative. The files will always be opened and saved to the same path the script is run from. Ive looked at GetParentFolderName and GetAbsolutePathName. However I cant figure how to call the fully qualified path in the text. I've tried just putting the variable where the file name is with and without quotes, appended it with a period.
Any example on building the function or whatever, and then calling it in the code below would be a huge help.
Dim myXL
Const xlDelimited = 1
Const xlWorkbookNormal = -4143
Set myXL=CreateObject("Excel.Application")
myXL.Visible=False
myXL.WorkBooks.OpenText "file.csv", , , xlDelimited, , , , , True
myXL.DisplayAlerts=False
MORE CODE WILL GO HERE
myXL.ActiveWorkbook.SaveAs "new_file.xls", xlWorkbookNormal
myXL.DisplayAlerts=True
myXL.ActiveWorkbook.Close False
myXL.Quit
Set myXL = Nothing
You can get the path of your script by using this code that i Found at an answer about Relative Path
p should be the path to your script you can then edit
"file.csv"
top & "\file.csv"
and so.To point out/emphasize that
&
not.
(dot/period):