To handle other Office application from Excel, you need to create an object using CreateObject Function (or tick appropriate reference from Tools > References menu of VBE.)
In the first case, s Constance like "wdGoToBookmark" is not recognized in Excel as it is.
So you need to TELL excel what does wdGoToBookmark stand for. (You can get the value of "wdGoToBookmark" in Word application.)
The following code works on Excel.
Code:Const wdGoToBookmark As Long = -1 Const wdFieldEmpty As Long = -1 Dim appWord As Object Dim BMRange As Object Set appWord = CreateObject("Word.Application") With appWord .Visible = True .documents.Open ("C:\Doc1") 'Change Here Set BMRange = .ActiveDocument.Bookmarks("WordBM").Range .Selection.Goto What:=wdGoToBookmark, Name:="WordBM" .Selection.Fields.Add Range:=.Selection.Range, Type:=wdFieldEmpty, _ Text:="LINK Excel.Sheet.8 " & docname & " Sheet1!ExcelRange" & _ formatting, PreserveFormatting:=False .ActiveDocument.Bookmarks.Add Range:=BMRange, Name:="WordBM" End With


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks