OK, I’ve searched all the expected forums of Word, VBA and Excel and I can’t find a solution for this. I’ve also searched MSDN and come up with a partial solution but not one fitting my problem, so please forgive me if this has been asked before:-
can anyone please help with copying data from excel specified cell addresses into predefined bookmarks within Word 97. The MSDN solution seemed to copy consecutive cells into consecutive bookmarks, but I want to copy specific addressed cells into specific named bookmarks.
I got partway with the Word doc (i.e. opening up from specified filepathname) but the
BMRange = ActiveDocument.Bookmarks(“MyBookmark”).Range bombed out every time with object error.
I had thought of copying the data to a new workbook – closing the new workbook and then opening a predefined merge document, but this seems a little less ‘slick’ than I would have hoped for.
Part of code is:
Dim BMRange As Range
MyItem = ActiveSheet.Range(“D6”).Value
OpenFile = ActiveSheet.Range(“D3”).value
‘ Start Word and create an object
Set WordApp = CreateObject(“Word.Application”)
‘ Send commands to Word
With WordApp
.Application.Visible = True
.documents.Open FileName:=OpenFile ‘open an existing file from worksheet cell value
End With
With WordApp
BMRange = activedocument.Bookmarks(“MyBookmark”).Range ‘runtime error 424
BMRange.Text = MyItem
.activedocument.bookmark.Add “MyBookmark”, BMRange
Obviously its only a section of the code and once sorted I would hope to use other cells values to populate further bookmarks in the document.
Much appreciate any help
Alan
Cheshire
UK