PC Review


Reply
Thread Tools Rate Thread

Closing, Saving question

 
 
Fritz Hilgemann
Guest
Posts: n/a
 
      30th Jul 2009
Hello,

I really hope I am right here. I am programming an excel client in c#, and I
try to start excel with an empty workbook and then save it with a given
filepath.
Empty workbook seems ok:
object missing = System.Reflection.Missing.Value;

appExcel.Visible = true;

wb = (Workbook)appExcel.Workbooks.Add(missing);

However, when I try to Close(...) or SaveAs(...), excel allways comes up
with the messagebox if I want to override the existing file.

Example:

wb.Close(true,"d:\\Excelsheet.xls",false);

appExcel.Workbooks.Close();

appExcel.Quit();



My question: How can I prevent excel from displaying the messagebox, and
save the file in any case ?

Weired, in the case above, if I answer the messagebox with "no", I get an
exception on the wb.Close() call.



Thank you for any hints

Fritz


 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      30th Jul 2009
In VBA, you can use

WB.Close SaveChanges:= True

Is there something in c# that's similar?

"Fritz Hilgemann" wrote:

> Hello,
>
> I really hope I am right here. I am programming an excel client in c#, and I
> try to start excel with an empty workbook and then save it with a given
> filepath.
> Empty workbook seems ok:
> object missing = System.Reflection.Missing.Value;
>
> appExcel.Visible = true;
>
> wb = (Workbook)appExcel.Workbooks.Add(missing);
>
> However, when I try to Close(...) or SaveAs(...), excel allways comes up
> with the messagebox if I want to override the existing file.
>
> Example:
>
> wb.Close(true,"d:\\Excelsheet.xls",false);
>
> appExcel.Workbooks.Close();
>
> appExcel.Quit();
>
>
>
> My question: How can I prevent excel from displaying the messagebox, and
> save the file in any case ?
>
> Weired, in the case above, if I answer the messagebox with "no", I get an
> exception on the wb.Close() call.
>
>
>
> Thank you for any hints
>
> Fritz
>
>
>

 
Reply With Quote
 
Fritz Hilgemann
Guest
Posts: n/a
 
      30th Jul 2009
Yes, but appearently it does not prevent the messagebox. In the code line
wb.Close(true,"d:\\Excelsheet.xls",false); (see orig. message)
the first parameter is named "SaveChanges".

Fritz

"Barb Reinhardt" <(E-Mail Removed)> wrote in message
news:C0838D54-A134-4192-9714-(E-Mail Removed)...
> In VBA, you can use
>
> WB.Close SaveChanges:= True
>
> Is there something in c# that's similar?
>
> "Fritz Hilgemann" wrote:
>
>> Hello,
>>
>> I really hope I am right here. I am programming an excel client in c#,
>> and I
>> try to start excel with an empty workbook and then save it with a given
>> filepath.
>> Empty workbook seems ok:
>> object missing = System.Reflection.Missing.Value;
>>
>> appExcel.Visible = true;
>>
>> wb = (Workbook)appExcel.Workbooks.Add(missing);
>>
>> However, when I try to Close(...) or SaveAs(...), excel allways comes up
>> with the messagebox if I want to override the existing file.
>>
>> Example:
>>
>> wb.Close(true,"d:\\Excelsheet.xls",false);
>>
>> appExcel.Workbooks.Close();
>>
>> appExcel.Quit();
>>
>>
>>
>> My question: How can I prevent excel from displaying the messagebox, and
>> save the file in any case ?
>>
>> Weired, in the case above, if I answer the messagebox with "no", I get an
>> exception on the wb.Close() call.
>>
>>
>>
>> Thank you for any hints
>>
>> Fritz
>>
>>
>>



 
Reply With Quote
 
Fritz Hilgemann
Guest
Posts: n/a
 
      30th Jul 2009
Uuh, I just got it, although it is a little weired:
appExl.DisplayAlerts = false;

Thanks anyway!
Fritz

"Fritz Hilgemann" <(E-Mail Removed)> wrote in message
news:h4s12c$jod$(E-Mail Removed)...
> Yes, but appearently it does not prevent the messagebox. In the code line
> wb.Close(true,"d:\\Excelsheet.xls",false); (see orig. message)
> the first parameter is named "SaveChanges".
>
> Fritz
>
> "Barb Reinhardt" <(E-Mail Removed)> wrote in
> message news:C0838D54-A134-4192-9714-(E-Mail Removed)...
>> In VBA, you can use
>>
>> WB.Close SaveChanges:= True
>>
>> Is there something in c# that's similar?
>>
>> "Fritz Hilgemann" wrote:
>>
>>> Hello,
>>>
>>> I really hope I am right here. I am programming an excel client in c#,
>>> and I
>>> try to start excel with an empty workbook and then save it with a given
>>> filepath.
>>> Empty workbook seems ok:
>>> object missing = System.Reflection.Missing.Value;
>>>
>>> appExcel.Visible = true;
>>>
>>> wb = (Workbook)appExcel.Workbooks.Add(missing);
>>>
>>> However, when I try to Close(...) or SaveAs(...), excel allways comes up
>>> with the messagebox if I want to override the existing file.
>>>
>>> Example:
>>>
>>> wb.Close(true,"d:\\Excelsheet.xls",false);
>>>
>>> appExcel.Workbooks.Close();
>>>
>>> appExcel.Quit();
>>>
>>>
>>>
>>> My question: How can I prevent excel from displaying the messagebox, and
>>> save the file in any case ?
>>>
>>> Weired, in the case above, if I answer the messagebox with "no", I get
>>> an
>>> exception on the wb.Close() call.
>>>
>>>
>>>
>>> Thank you for any hints
>>>
>>> Fritz
>>>
>>>
>>>

>
>



 
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
Database Saving/Closing question =?Utf-8?B?YXJjaGl2aXN0MjIz?= Microsoft Access Getting Started 1 15th Nov 2007 09:29 PM
Prompting user to answer a question before saving and closing wkbo =?Utf-8?B?SnVzdEJyZWF0aGU=?= Microsoft Excel Programming 5 8th Mar 2007 10:55 PM
Re: closing & saving vezerid Microsoft Excel Worksheet Functions 0 3rd Mar 2006 04:36 PM
saving before closing =?Utf-8?B?SmFzb24gWmlzY2hrZQ==?= Microsoft Excel Programming 2 7th Dec 2005 08:57 AM
Closing without saving =?Utf-8?B?UGFt?= Microsoft Frontpage 1 7th Feb 2004 01:40 PM


Features
 

Advertising
 

Newsgroups
 


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