Using InputBox to capture and re-use information in Word?

Posted on 2006-03-31
Last Modified: 2010-04-07
How do I use an InputBox to capture information and use it to populate the Document Properties in a Word Document?
Question by:yecala
    LVL 76

    Expert Comment

    This code uses early binding for most of the objects, so set a reference to the Microsoft Word object library.
    LVL 76

    Accepted Solution

    Well this code does, anyway.

    Private Sub SetPropertyValue(strDoc As String)
        Dim oDoc As Word.Document
        Dim oWord As Word.application
        Dim strPropValue As String
        Dim oDpr As Object 'DocumentProperty
        Set oWord = New Word.application
        oWord.Visible = True ' set word visible until all developement bugs eliminated. Otherwise you can leave invisible instances of WinWord running
        Set oDoc = oWord.Documents.Open(strDoc)
        Set oDpr = oDoc.BuiltInDocumentProperties(wdPropertyAuthor)
        oDpr.Value = InputBox("Please give a new name for the Author", "Document Property", oDpr.Value)
    End Sub
    LVL 1

    Expert Comment

    If you are starting from Word, also you can add word fields in the document so anyone can fill values to document properties directly on word.


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now