Can I easily add 'date last saved' field?

C

CJSnet

Hi, as above really. Word has this option for its fields but I can't find
how to do it *easily* in Excel :)
--
Thanks.

CJSnet

(Remove TEETH to reply by e-mail.)
 
B

Bob Phillips

USing VBA

Function DocProps(prop As String)
application.volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function


and enter in a cell
=DOCPROPS("last save time")
(format cell as date)

This is a custom UDF, so you need to place the code in a normal code module.



--

HTH

RP
(remove nothere from the email address if mailing direct)
 
C

CJSnet

Thanks, and how do I do that? :-S
--
Thanks.

CJSnet

(Remove TEETH to reply by e-mail.)
 
B

Bob Phillips

I explained all that.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
C

CJSnet

Sorry, I can't see how to "place the code in a normal code module." I'm not
familiar with such processes and would appreciate brief point in the right
direction :)
--
Thanks.

CJSnet

(Remove TEETH to reply by e-mail.)
 
B

Bob Phillips

Okay, let's go :).

If you want it just for one workbook, activatev that workbook.
First go into the VBE - Alt-F11
Then go to the Insert>Module menu, a code pane window will popup
Copy my code into that window
Close the VBE (x in the corner is OK)
Now test it in the workbook, and save the workbook.

If you want it as a general purpose function, then we'll put it in
Personal.xls
Go to menu Tools>Macro>Record New Macro
In the 'Store macro in' dropdown, select Personal.xls
Give the macro any old name (we will remove it later)
Stop the macro (Tools>Macro>Stop Recording)
Go into the VBE - Alt-F11
Select Personal.xls fro the list of workbooks in the project explorer
Open all sections (the + sign)
In the Modules section, select Module1 and paste the code in.
Close the VBE.
Test it. You will now need to use =Personal.xls!DocProps("last save time")

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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