Hello everyone.
To sot of branch off from an earlier thread. I have an excel spreadsheet with student data. I can get the listview data to export data to excel, and now the excel spreadsheet is open, but I am not trying to figure out how to close and save.
I have been searching, and found this code that might do the trick, I have modified it with my save path, but it is asking me to declare objects.
The line Dim oXLApp As Excel.Application for ex, asks me to declare objects, but didn't the Dim declare it?
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Set oXLApp = New Excel.Application 'Create a new instance of Excel
Set oXLBook = oXLApp.Workbooks.Add 'Add a new workbook
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet
Set oXLSheet = Nothing 'disconnect from the Worksheet
'oXLBook.SaveAs "C:\My Documents\My File.xls" 'Save (and disconnect from) the Workbook
oXLBook.SaveAs App.Path & "\TrackerSettings\Roster" & LiteracyStation.RosChosenNumTXT.Text & "\SavedTrackerCharts\Literacy Station Picks - " & LiteracyStationWeekView.Caption & Format(Date, "dd-mm-yyyy") & " - " & Format(Time$, "hh-mm-ss") & ".xls"
oXLBook.Close SaveChanges:=False
Set oXLBook = Nothing
oXLApp.Quit 'Close (and disconnect from) Excel
Set oXLApp = Nothing
This is a new spreadsheet, and I just need it to close and save with the app.path I have up there, so is all of this code necessary for just saving an already open excel spreadsheet? Thank you!!
To sot of branch off from an earlier thread. I have an excel spreadsheet with student data. I can get the listview data to export data to excel, and now the excel spreadsheet is open, but I am not trying to figure out how to close and save.
I have been searching, and found this code that might do the trick, I have modified it with my save path, but it is asking me to declare objects.
The line Dim oXLApp As Excel.Application for ex, asks me to declare objects, but didn't the Dim declare it?
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Set oXLApp = New Excel.Application 'Create a new instance of Excel
Set oXLBook = oXLApp.Workbooks.Add 'Add a new workbook
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet
Set oXLSheet = Nothing 'disconnect from the Worksheet
'oXLBook.SaveAs "C:\My Documents\My File.xls" 'Save (and disconnect from) the Workbook
oXLBook.SaveAs App.Path & "\TrackerSettings\Roster" & LiteracyStation.RosChosenNumTXT.Text & "\SavedTrackerCharts\Literacy Station Picks - " & LiteracyStationWeekView.Caption & Format(Date, "dd-mm-yyyy") & " - " & Format(Time$, "hh-mm-ss") & ".xls"
oXLBook.Close SaveChanges:=False
Set oXLBook = Nothing
oXLApp.Quit 'Close (and disconnect from) Excel
Set oXLApp = Nothing
This is a new spreadsheet, and I just need it to close and save with the app.path I have up there, so is all of this code necessary for just saving an already open excel spreadsheet? Thank you!!