![]() |
HELP! Programmicly Save an Excel File ?
I am exporting data from a GIS application to Excel.
I am currently just opening a tab delimited file in excel. The file that opens is somename.txt but it is in excel. To accually get an 'excel' file the user must do a save as .xls. I would like to save the somename.txt as somename.xls to take that step out or the operation. I would also like the excel file so I can manipulate it and create some new worksheets and compile some simple statistics. Current Code: Open filepath_Export & "Selection_Set.txt" For Output As #1 Print #1, strHeaderRow & vbCr & sData Close #1 'Open the new text file in Excel Shell GetAssociatedExecutable(".xls") & " " & _ Chr(34) & filepath_Export & "Selection_Set.txt" & Chr (34), vbNormalFocus Some code here to save the file or active window file or something Thanks, Charles |
HELP! Programmicly Save an Excel File ?
Solved my own problem Solution.. Record a macro and stick it on a button. Dim plGetPathString As String Dim filepath As String plGetPathString = "" filepath = Trim$(ActiveWorkbook.FullName) While InStr(filepath, "\") plGetPathString = plGetPathString & Left$(filepath, InStr(filepath, "\")) filepath = Mid$(filepath, InStr(filepath, "\") + 1) Wend If Len(Dir("" & plGetPathString & "Selection_Set.xls")) 1 Then 'MsgBox "file exists" ActiveWorkbook.SaveAs Filename:="" & plGetPathString & "Selection_Set_" & Rnd() & ".xls", FileFormat _ :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _ False, CreateBackup:=False, Accessmode:=xlNoChange, ConflictResolution:=xlUserResolution Else ActiveWorkbook.SaveAs Filename:="" & plGetPathString & "Selection_Set.xls", FileFormat _ :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _ False, CreateBackup:=False, Accessmode:=xlNoChange, ConflictResolution:=xlUserResolution End If |
All times are GMT +1. The time now is 05:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com