K
Kjartan Valdimarsson
I have not done this before, struggled for hours but can't figure it out or
find any readings about it...
From a form, I want to open an Excel worksheet, set a date in a cell (and
some other changes not listed here), print the sheet and then close Excel
without saving the changes. The last version of my code is as follows. I
appreciate your help solving the problems I still have:
Set objXL = CreateObject("Excel.Application")
With objXL.Application
.Visible = True
.Workbooks.Open "C:\PM\PMs"
.Sheets("Daily Checklist").Select
.Cells(3, 2).Formula = Date
'*** Prepare the sheet for printing does NOT work... ***
.ActiveSheet.PageSetup.Orientation = "xlPortrait"
'*** Print sheet - Works, but comes out as Landscape... ***
.ActiveWindow.SelectedSheets.PrintOut
'*** The workbook closes, but I don't want the dialog asking if I
want to save the changes...***
'*** also, I want Excel to close if there are no other workbooks are
open in Excel...***
.Workbooks.Close
End With
Set objXL = Nothing
Thank's in advance,
Kjartan
find any readings about it...
From a form, I want to open an Excel worksheet, set a date in a cell (and
some other changes not listed here), print the sheet and then close Excel
without saving the changes. The last version of my code is as follows. I
appreciate your help solving the problems I still have:
Set objXL = CreateObject("Excel.Application")
With objXL.Application
.Visible = True
.Workbooks.Open "C:\PM\PMs"
.Sheets("Daily Checklist").Select
.Cells(3, 2).Formula = Date
'*** Prepare the sheet for printing does NOT work... ***
.ActiveSheet.PageSetup.Orientation = "xlPortrait"
'*** Print sheet - Works, but comes out as Landscape... ***
.ActiveWindow.SelectedSheets.PrintOut
'*** The workbook closes, but I don't want the dialog asking if I
want to save the changes...***
'*** also, I want Excel to close if there are no other workbooks are
open in Excel...***
.Workbooks.Close
End With
Set objXL = Nothing
Thank's in advance,
Kjartan