Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB to access and change Document Properties (Word 97)

    When my document is opened I want to test to see if there is anything in the Keywords document property. If there is, then I want the macro to stop. If not, I want to prompt the user for an entry.

    How can I do this?

    Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VB to access and change Document Properties (Word 97)

    Start the Visual Basic Editor (Alt+F11).
    Make sure the Project Explorer is visible (Ctrl+R).
    Expand the document or template you're working on.
    Double click ThisDocument (in Microsoft Word Objects).
    Enter the following code:

    Private Sub Document_Open()
    Dim strKeywords As String
    If ActiveDocument.BuiltInDocumentProperties("Keywords ") = "" Then
    strKeywords = InputBox("Enter keywords for this document")
    If strKeywords <> "" Then
    ActiveDocument.BuiltInDocumentProperties("Keywords ") = strKeywords
    Else
    ' If user doesn't provide keywords, you can handle that here.
    End If
    End If
    End Sub

    HTH,
    Hans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •