ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   workbook.saved property (https://www.excelbanter.com/excel-programming/346285-workbook-saved-property.html)

Jan[_17_]

workbook.saved property
 
Hi all

I wrote some VBA code which should detect if the workbook has just been
created through a template or already been saved (*.xls). When testing
for the Saved property I was a little bit confused finding the value
already set TRUE.

Private Sub Workbook_Open()
If ThisWorkbook.Saved = True Then
'jop - never been saved, empty path. saved is TRUE anyway???
GoTo WBSaved
End If
End Sub

Has anybody an explanation for this or is it a bug (solution,
workaround ?).
There exist postings about confusing behaviour of 'Workbook.Saved'
property value. But I didn't find a suitable solution for my problem,
yet.

Any ideas, suggestions? Thanks!


Jan[_17_]

workbook.saved property
 
Sorry, I forgot!

Running on WindowsXP Professional (SP2), Microsoft Excel 2002 (SP3).

I already tried to use 'auto_new()', as used in word, but this does not
work at all ...


Dave Peterson

workbook.saved property
 
If you're creating the workbook from a template (.xlt), then you can check the
path:

Private Sub Workbook_Open()
If ThisWorkbook.Path = "" Then
'never saved, just created
else
'already saved once
end if
End Sub

Jan wrote:

Hi all

I wrote some VBA code which should detect if the workbook has just been
created through a template or already been saved (*.xls). When testing
for the Saved property I was a little bit confused finding the value
already set TRUE.

Private Sub Workbook_Open()
If ThisWorkbook.Saved = True Then
'jop - never been saved, empty path. saved is TRUE anyway???
GoTo WBSaved
End If
End Sub

Has anybody an explanation for this or is it a bug (solution,
workaround ?).
There exist postings about confusing behaviour of 'Workbook.Saved'
property value. But I didn't find a suitable solution for my problem,
yet.

Any ideas, suggestions? Thanks!


--

Dave Peterson


All times are GMT +1. The time now is 10:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com