workbook.saved property

  • Thread starter Thread starter Jan
  • Start date Start date
J

Jan

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!
 
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 ...
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top