.GoTo what:=wdGoToBookmark, _
Name:=”EnvelopeNameTitleCompany”
.TypeText Text:=strNameTitleCompany
.GoTo what:=wdGoToBookmark, _
Name:=”EnvelopeWholeAddress”
.TypeText Text:=strWholeAddress
.GoTo what:=wdGoToBookmark, Name:=”ZipCode”
.TypeText Text:=Nz(lst.Column(6, varItem))
End With
Re-insert bookmark:
With appWord.Selection
.MoveLeft _
unit:=wdWord, Count:=3, _
Extend:=wdExtend
.Font.Hidden = True
End With
Re-hide zip code.
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:=”ZipCode”
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
On Error GoTo ErrorHandler
Check for a previously saved document in the documents folder, and append an incremented
number to the save name if one is found:
strDocType = _
appWord.ActiveDocument.
BuiltInDocumentProperties(wdPropertyTitle)
strSaveName = strDocType & “ to “ _
& strContactName & “ - “ & strCompanyName
strSaveName = strSaveName & “ on “ _
& strShortDate & strExtension
i = 2
intSaveNameFail = True
Do While intSaveNameFail
strSaveNamePath = strDocsPath & strSaveName
Debug.Print “Proposed save name and path: “ _
& vbCrLf & strSaveNamePath
strTestFile = Nz(Dir(strSaveNamePath))
Debug.Print “Test file: “ & strTestFile
If strTestFile = strSaveName Then
Debug.Print “Save name already used: “ _
& strSaveName
Part II Writing VBA Code to Exchange Data between Office Components