PC Review


Reply
Thread Tools Rate Thread

Create new workbook and new worksheet and close. Worksheet not saved

 
 
Patrick
Guest
Posts: n/a
 
      23rd Jul 2009
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


 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      25th Jul 2009
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" <(E-Mail Removed)> wrote in message
news:e583f278-7212-4fbc-8351-(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Microsoft Excel Programming 0 21st Jul 2009 02:19 PM
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Microsoft Excel Worksheet Functions 0 20th Jul 2009 07:10 PM
Worksheet saved out as new workbook =?Utf-8?B?VE9NQg==?= Microsoft Excel Programming 3 14th Nov 2007 07:53 PM
Check Worksheet When Workbook Is Saved =?Utf-8?B?Q2xhcmU=?= Microsoft Excel Programming 2 15th Oct 2007 09:12 PM
When saving workbook only the first worksheet gets saved. Debutante Microsoft Excel Worksheet Functions 5 18th Dec 2004 01:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:12 AM.