Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using interop.excel to open a workbook, the workbook doesn't ask to save changes.

I'm using C# and the Interop.Excel assembly to programatically open an
..xls file, make some changes, then save the changes.
The code works fine, the changes are saved, etc. But when I use excel
to open the file, then make some changes manually, Excel no longer
prompts me to save my changes - it just closes the file without saving.

here is the C# code that I'm running. Before I run this code, junk.xls
works normally. It prompts for changes, etc. After I run this code,
junk.xls no longer prompts me to save any changes that I've made. This
code doesn't even change or save junk.xls (as far as I can tell). Can
anyone help?

Excel.ApplicationClass app = new Excel.ApplicationClass();
Excel.Workbook wb2 = (Excel.Workbook)app.Workbooks.Open(
"c:\\temp\\junk2.xls",
false,
false,
Type.Missing,
Type.Missing,
Type.Missing,
true,
Type.Missing,
Type.Missing,
true,
false,
Type.Missing,
false,
Type.Missing,
true);

wb2.Close(false, Type.Missing, Type.Missing);
app.Quit();

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Using interop.excel to open a workbook, the workbook doesn't ask to save changes.

I don't know C#, but as a guess maybe one of those false's is doing the VBA
equivalent of

Application.DisplayAlerts = False

This is an application level setting that needs to be reset to True.

Regards,
Peter T

wrote in message
oups.com...
I'm using C# and the Interop.Excel assembly to programatically open an
.xls file, make some changes, then save the changes.
The code works fine, the changes are saved, etc. But when I use excel
to open the file, then make some changes manually, Excel no longer
prompts me to save my changes - it just closes the file without saving.

here is the C# code that I'm running. Before I run this code, junk.xls
works normally. It prompts for changes, etc. After I run this code,
junk.xls no longer prompts me to save any changes that I've made. This
code doesn't even change or save junk.xls (as far as I can tell). Can
anyone help?

Excel.ApplicationClass app = new Excel.ApplicationClass();
Excel.Workbook wb2 = (Excel.Workbook)app.Workbooks.Open(
"c:\\temp\\junk2.xls",
false,
false,
Type.Missing,
Type.Missing,
Type.Missing,
true,
Type.Missing,
Type.Missing,
true,
false,
Type.Missing,
false,
Type.Missing,
true);

wb2.Close(false, Type.Missing, Type.Missing);
app.Quit();



Reply
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
Code to open new workbook, prompt for 'save as' name. Mark Excel Programming 1 April 5th 05 10:49 PM
Why when i have more than one workbook open and i want to save ch. Jaykhi New Users to Excel 2 March 17th 05 05:21 AM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
Excel Workbook opened twice with dotnet interop Steve Weixel Excel Programming 0 August 25th 03 11:37 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


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

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

About Us

"It's about Microsoft Excel"