Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Version Number 1

Status
Not open for further replies.

cwsstins

MIS
Aug 10, 2004
412
US
Do MS Office products keep track of version numbers? If so, is it possible to enter a file version number into the header/footer of a document or spreadsheet?

Specifically, I'm trying to do this with MS Excel 2000 on an XP OS.

stinsman
 
The only way I know how to do this is through VBA.

Code:
Sub InsertVersionFooter()
    With ActiveSheet.PageSetup
        .LeftFooter = "Excel Version " & Application.Version
    End With
End Sub

HTH,
Eric
 
Actually, I don't want the application version...I'm looking for the file version number. For instance, if this file has been updated/saved 14 times, its version # would be 14. Similar to what a version control system will do for code...I'm thinking this is probably not possible with Excel...
 
You could increment a cell value each time a file is saved, hen insert a footer with the value.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
[a1] = [a1] + 1
End Sub
HTH,
Eric
 
Eric, that's outstanding!!! How about if I wanted to add today's date (the date when the file is revised) as well?

 
Try this. I'm using 2002 so I'm not sure when the BuiltInDocumentProperties property came into being.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
[a1] = [a1] + 1
    With ActiveSheet.PageSetup
        .LeftFooter = "Version # " & [a1] & vbCrLf _
        & ThisWorkbook.BuiltinDocumentProperties(12)
    End With
End Sub

HTH,
Eric
 
Just remember that BuiltinDocumentProperties is a counter of the number of saves. So if in one session, you saved the file four times, the Version number is increased by 4.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top