Share via

Changing document properties with VBA

Anonymous
2018-08-24T10:07:39+00:00

I can change the version number of an Excel file by using the file's Properties panel.  I would like to be able to set this from a VBA module.  Is it possible?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Andreas Killer 144.1K Reputation points Volunteer Moderator
2018-08-24T10:18:45+00:00

Sub Test() With ThisWorkbook With .BuiltinDocumentProperties .Item("Document version") = 123 End With .Save End With End Sub

Note: You must close the file to see the changes within the Windows Explorer!

Andreas.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-08-25T09:24:07+00:00

    Hi Dave

    Thanks for your reply.

    I couldn't get the code working, but since I only need it for Excel I used this (courtesy of Andreas Killer):

    Sub Test() With ThisWorkbook With .BuiltinDocumentProperties .Item("Document version") = 123 End With .Save End With End SubCheersAlan

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-08-25T09:18:39+00:00

    Hi Andreas

    That's exactly what I wanted.  I'm not sure why I didn't find it myself, but I do find the MS site extremely difficult to navigate.

    Many thanks

    Alan

    Was this answer helpful?

    0 comments No comments
  3. DaveM121 891K Reputation points Independent Advisor
    2018-08-24T10:13:34+00:00

    Hi Alan, this code should do that for you . ..

    With .Add(Name:="UFVersion", LinkToContent:=False, _

        Type:=msoPropertyTypeString, Value:="UserFormVersion1.2.1a")
    
    End With
    

    Was this answer helpful?

    0 comments No comments