Sample code to
change the Title value as a variable in Word with a Textbox Control.
In Word you can
import and modify internal and user-defined variables directly in the document.
Internal variables can be externally best with Title.
If you want to use
a property directly in a document as a variable, you can use a textbox control
for the input in the example shown and adjust the title as you type in the
textbox element.
The assignment is
made with
ActiveDocument.BuiltInDocumentProperties("Title") = tbxNr.Value
|
The advantage of
using MS Word document properties is that they can also be viewed directly in
the file explorer.
This makes it easy
to manage Word documents via the File Explorer.
As you can see,
authors, categories, markers, and titles are placed directly in the file
overview.
The internal
variables or properties can be found in Microsoft Word under Menu bar->
Insert-> Fast blocks
Then document
properties:
Author, subject,
company, company address, category, comments, summary, keywords, status, title.
The easiest
variables should be: title, status, subject, category, and summary
The following VBA
code in MS Word directly changes the property [Title]
Option Explicit On
Private Sub
tbxNr_Change()
'----<
tbxNr_Change() >----
'*change
internal variable propertie Title
ActiveDocument.BuiltInDocumentProperties("Title") =
tbxNr.Value
'----</
tbxNr_Change() >----
End Sub
|
Subject: Field,
Field, Variable, Property, Property,