ShadowFox333
Programmer
I want to import a .csv file into an excel worksheet
and then modify one of the columns from numeric to text.
The code below does opens excel and inputs the .csv file to a worksheet. I can't figure out how to modify the column property. TIA.
Bob
Option Explicit
Const vbNormal = 1
DIM objXL, objWb, objR ' Excel object variables
DIM Title, Text, tmp, i, j, file, name
Title = "WSH sample - by G. Born"
file = "00130.csv"
name = "00130"
' create an Excel object reference
Set objXL = WScript.CreateObject ("Excel.Application")
objXL.WindowState = vbNormal ' Normal
objXL.Height = 300 ' height
objXL.Width = 400 ' width
objXL.Left = 40 ' X-Position
objXL.Top = 20 ' Y-Position
objXL.Visible = true ' show window
' Load the Excel file from the script's folder
Set objWb = objXl.WorkBooks.Open(GetPath+file)
' Get the loaded worksheet object
Set objWb = objXL.ActiveWorkBook.WorkSheets("00130")
objWb.Activate ' not absolutely necessary (for CSV)
WScript.Echo "worksheet imported"
objXl.Quit()
Set objXL = Nothing
WScript.Quit()
Function GetPath
' Retrieve the script path
DIM path
path = WScript.ScriptFullName ' Script name
GetPath = Left(path, InstrRev(path, "\"))
End Function
and then modify one of the columns from numeric to text.
The code below does opens excel and inputs the .csv file to a worksheet. I can't figure out how to modify the column property. TIA.
Bob
Option Explicit
Const vbNormal = 1
DIM objXL, objWb, objR ' Excel object variables
DIM Title, Text, tmp, i, j, file, name
Title = "WSH sample - by G. Born"
file = "00130.csv"
name = "00130"
' create an Excel object reference
Set objXL = WScript.CreateObject ("Excel.Application")
objXL.WindowState = vbNormal ' Normal
objXL.Height = 300 ' height
objXL.Width = 400 ' width
objXL.Left = 40 ' X-Position
objXL.Top = 20 ' Y-Position
objXL.Visible = true ' show window
' Load the Excel file from the script's folder
Set objWb = objXl.WorkBooks.Open(GetPath+file)
' Get the loaded worksheet object
Set objWb = objXL.ActiveWorkBook.WorkSheets("00130")
objWb.Activate ' not absolutely necessary (for CSV)
WScript.Echo "worksheet imported"
objXl.Quit()
Set objXL = Nothing
WScript.Quit()
Function GetPath
' Retrieve the script path
DIM path
path = WScript.ScriptFullName ' Script name
GetPath = Left(path, InstrRev(path, "\"))
End Function