Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Kyle,
it may seem obvious... have you tried opening the files as read-only? then he has no need to 'mark' the original keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "?B?S3lsZSBCYWxleQ==?=" wrote: This is a question about working with Excel from .NET so if this is the wrong newsgroup, please let me know. Technologies are .NET Framework 1.1, C#, Excel 2003. I have a Windows Forms app that is extracting information from about 450 similarly formatted spreadsheets. So I'm opening the spreadsheet, extracting the info into a dataset, closing the spreadsheet and moving on to the next one. I always get an error when opening some spreadsheets. It's not the spreadsheets because it fails on different ones each time through. E.g. It will fail on the twelfth one the first time, then the twenty-third one the next time, and so on. It's not a .NET error (so I can't trap it in a try-catch block). When it fails, a dialog appears with Microsoft Visual Basic as the title (I'm using C#) and the message is "File already exists". Note that I have Interactive set to false for the Excel application. My theory is that I'm opening and closing spreadsheets too fast because when I put a Thread.Sleep(100) between the Close/Open statements, it works (although much slower than I'd like). I suspect that Excel is creating a temporary file based on the current time when the spreadsheet is opened and isn't deleting it fast enough when it is closed. So when the next spreadsheet is opened in the same "time frame" it tries to create a new temp file with the same name. One final note: If I don't reference the Worksheets collection of the workbook, no error occurs. It fails only when I starting working with the sheets in the workbook (even if all I do is set a variable to workbook.Worksheets.Count). |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, should have specified. I'm opening the files read-only.
Other parameters: - UpdateLinks: false - WriteResPassword: false - IgnoreReadOnlyRecommended: true - Editable: false - Notify: false - AddToMru: false - Local: false All other parameters are set to System.Reflection.Missing.Value |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() i'm sure you've disabled: Application .enableevents = false BUT what are your settings for autorecover? (it's played havoc on some of my apps) .autorecover.enabled=false either disable application.autorecover or set the workbooks property after opening Workbook.enableautorecover = false else have a look at any other workbook properties that just might slow you down... sorry, that's it from me :-( keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "?B?S3lsZSBCYWxleQ==?=" wrote: Sorry, should have specified. I'm opening the files read-only. Other parameters: - UpdateLinks: false - WriteResPassword: false - IgnoreReadOnlyRecommended: true - Editable: false - Notify: false - AddToMru: false - Local: false All other parameters are set to System.Reflection.Missing.Value |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good suggestions. I hadn't disabled events or auto-recover but it didn't help. Try some other options but they other made no difference or cause COM exceptions. Even tried setting ReadOnly to true but alas.
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good suggestions. I hadn't disabled events or autorecover but doing so didn't help. Tried some other options in the Open event and even tried setting ReadOnly to false but they other didn't work or caused COM exceptions.
|
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() including (some) doevents might work wonders. (dont know the c equivalent, I'm just a simple VBA hack) it will give either excel enough ticks to to complete calculations, and you should allow some ticks to the OS to finish it's filehandling. (dont know what your data entails :) also make sure your temp directory is cleaned regularly.... no joke :( depending on the contents of files (embedded ole objects/pictures) excel can dump an awfull amount of data in temp... and certainly when developing (and crashing).. it tends to leave 'some of these' files behind... keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "?B?S3lsZSBCYWxleQ==?=" wrote: Good suggestions. I hadn't disabled events or autorecover but doing so didn't help. Tried some other options in the Open event and even tried setting ReadOnly to false but they other didn't work or caused COM exceptions. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Slow Opening & Odd Closing | New Users to Excel | |||
Closing a workbook upon opening another | New Users to Excel | |||
Opening and closing workbook with VBA... | Excel Programming | |||
Opening and Closing workbooks | Excel Programming | |||
Opening and closing text files | Excel Programming |