Date variable values

F

FotoArt

hello

I have a date variable formatted as follows
Format(MyLastSaved, "dddd, mmm d yyyy hh:mm")
When a new document is opened I know there wont be any lastsaved date. In
these instances the variable is giving me date as 1899 and time as 12:00:00
am.
Any idea why and how I could deal with it.
If theres no lastsaved date I want it not to appear.

any help will be appreciated
thanx
ahmed
 
P

Peter Jamieson

You don't say how you're using this value, but you can try:

Dim v As Variant
On Error Resume Next
v = ActiveDocument.BuiltInDocumentProperties(wdPropertyTimeLastSaved)
Err.Clear
On Error Goto 0
If VarType(v) = 0 Then
Debug.Print "Document Not Saved"
Else
Debug.Print v
End If

There may be easier ways, but unfortunately these empty properties don't
respond as you might hope to to IsEmpty(). In theory we ought to check that
the error number is the one we expect in this situation, too.

Peter Jamieson
 
K

Karl E. Peterson

FotoArt said:
hello

I have a date variable formatted as follows
Format(MyLastSaved, "dddd, mmm d yyyy hh:mm")
When a new document is opened I know there wont be any lastsaved date. In
these instances the variable is giving me date as 1899 and time as 12:00:00
am.
Any idea why

That date/time is the ZERO value in Microsoft-land. Try this in the immediate
window:

?format(0, "long date"), format(0, "long time")
Saturday, December 30, 1899 12:00:00 AM
and how I could deal with it.

Test for a value of 0, and branch accordingly.

If CDbl(MyLastSaved) = 0# Then
' Unsaved
Else
' Inject formatted value
End If
 

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

Top