LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Create new workbook and new worksheet and close. Worksheet not saved

don't confuse sheet save with workbook save. sheets are part of the workbook
so if wb is your workbook object and ws is a worksheet object
then
set ws = wb.worksheets.add()
will set ws to the worksheet object which has been created in the workbook
so
wb.save true
will save the workbook and thus all sheets. you don't need a ws.saveas
method as well


"Patrick" wrote in message
...
Hi,

I have scenario that users may give a filename and sheetname and both
are
not exiting. So I will create workbook by

Workbook.SaveAs(newWorkbookFullFileName, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode. xlNoChange,
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value);

and then the sheet by

Sheet.SaveAs(worksheet.Workbook.Name, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
Missing.Value, Missing.Value);


After that, users may close the appliation and I will do:


if (!Workbook.Saved)
{
Workbook.Save();
}

Workbook.Close(true, Missing.Value, Missing.Value);
App.Quit();


But when I use Excel to check the content of the file, the sheet
supposes to
be created as "SheetTest" is not there in the newly created workbook.
Am I
missing anything?

Thanks
Patrick


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Excel Programming 0 July 21st 09 02:19 PM
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Excel Worksheet Functions 0 July 20th 09 07:10 PM
Worksheet saved out as new workbook TOMB Excel Programming 2 November 14th 07 07:53 PM
Check Worksheet When Workbook Is Saved Clare Excel Programming 2 October 15th 07 09:12 PM
When saving workbook only the first worksheet gets saved. Debutante Excel Worksheet Functions 5 December 18th 04 01:31 AM


All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"