You can insert bookmarked texts from a Word Document (text files do not
support bookmarks) using IncludeText fields
If you want to read text from an ini file then you need a text file laid out
in sections like
[InvoiceNumber]
Order=2
[Print Number]
Order=1
[UserName]
Name = "Graham Mayor"
Phone = "99 123456"
Email = (e-mail address removed)
To read (say) the UserName section into a document, you can use a macro
similar to the following, which reads the three entries from the UserName
section and types them into the document. Here the text file is saved as
Settings.ini in the Word Startup folder.
Sub AddDataFromINIFile()
Dim SettingsFile As String
Dim Name As String
Dim EMail As String
Dim Phone As String
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
Name = System.PrivateProfileString(SettingsFile, _
"UserName", "Name")
Phone = System.PrivateProfileString(SettingsFile, _
"UserName", "Phone")
EMail = System.PrivateProfileString(SettingsFile, _
"UserName", "Email")
With Selection
.TypeText Text:=Name
.TypeParagraph
.TypeText Text:=Phone
.TypeParagraph
.TypeText Text:=EMail
End With
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>