by Max Martin (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 27th February 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Passing value from Visual Basic Application to MS Word (Document or Template) ' This code is for MS Word 7.0 and higher versions if you are
API Declarations
' The above one is for VB6 Check out for other versions
Dim WordObj As Word.Application
Dim WordDoc As Word.Document
Dim WordRange As Word.Range
Set WordObj = CreateObject("Word.Application")
' (.dot is a word template you can also use .doc a word document)
Set WordDoc = WordObj.Documents.Open("c:\test.doc")
WordObj.Visible = True
' Create a bookmark 'name' in the test.dot template or test.doc document
' The below code will place the text in the bookmarked location
Set WordRange = WordDoc.Goto(What:=wdGoToBookmark, Name:="name")
WordRange.InsertAfter "Max"
Set WordObj = Nothing
End Sub
No comments have been posted about Passing value from Visual Basic Application to MS Word (Document or Template) ' This code is for MS. Why not be the first to post a comment about Passing value from Visual Basic Application to MS Word (Document or Template) ' This code is for MS.