View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Workbook.Saved problem - bug or feature?

It might see the unprotect as a change and therefore would set the flag to
save the file.

"Mark" wrote:

I can't figure this one out, and it's driving me NUTS. Would
appreciate it if someone could point me in the right direction. I
have an application developed in Excel, which creates a new workbook,
writes out some data to it, saves it - and then leaves it open for the
user to view.

The problem I'm getting is the save status (Workbook.Saved property)
in the generated workbook is changing from True to False, when I
change a value in the *originating* workbook. Here's an example of
some tests I did in debug mode in the immediate window, following a
call to dbook.SaveAs ('dbook' references the generated workbook):

'
' Check current status of generated workbook
'
print dbook.Saved
True
print dbook.Name
netapp-bfgp1-APP01234-rd-20071022-0903-v1.xls
print dbook.Sheets("Audit History").protectcontents
True

'
' Check current status of originating workbook
'
print thisworkbook.Name
NAS Template Generator v2.0a.xls
print thisworkbook.Sheets("Audit History").protectcontents
True

'
' Unprotect the Audit History sheet in the originating workbook
' and view cell A2 of this sheet in both workbooks
'
thisworkbook.sheets("Audit History").unprotect "password"
print dbook.Saved
True
print thisworkbook.sheets("Audit History").range("A2").value
Event ID
print dbook.sheets("Audit History").range("A2").value
Event ID

'
' Change cell A2 in the originating workbook
'
thisworkbook.sheets("Audit History").range("A2").value = "Event ID2"

'
' Has it changed?
'
print thisworkbook.sheets("Audit History").range("A2").value
Event ID2

'
' And has it changed in the new workbook? (it shouldn't have because
' there are no formulas in this sheet, just plain values!)
'
print dbook.sheets("Audit History").range("A2").value
Event ID

'
' So.....?
'
print dbook.Saved
False


I'm baffled. Why has dbook been flagged as modified? Anyone??
What's going on here? The Audit History worksheet is nothing special,
it's just a spreadsheet with some values in it. No formulas. No
references from any other worksheet to the Audit History worksheet.
I've tried it with other worksheets and the same problem. It seems
whatever I change in the originating workbook, affects the save status
of the design workbook.

Please help!

Thanks in advance,
Mark.