Use Word bookmark in Excel spreadsheet

xlhelpme

Board Regular
Joined
Aug 17, 2010
Messages
53
I have an open Word template containing multiple bookmarks, I would like to add 2 specific bookmarks to an Excel spreadsheet when the spreadsheet is opened, the bookmarks names are “Text6” and “Text9”, the spreadsheet is launched from a button in the word template, with the following code:-
Sub OpenSheet()
ActiveDocument.FollowHyperlink _
Address:="C:\Common\Structure\Project\Working Area\Spreadsheet 2.0.xls", _
NewWindow:=True, AddHistory:=True
End Sub

I am using Word & Excel 2003, any suggestions would be appreciated as all the examples I can find open a pre-saved word document before copying bookmarks, will I have to save the Word doc to a temp location prior to locating and copying the bookmarks??

Thanks in anticipation.:confused:
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi
See if this example is useful for you:

Code:
Option Explicit
Dim xlApp As Excel.Application, xlWB As Excel.Workbook
Private Sub CommandButton1_Click()
Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set xlWB = xlApp.Workbooks.Open(ThisDocument.Path & "\Spreadsheet1.xls")
With xlWB.Worksheets(1)
    .Cells(6, 2).Value = ActiveDocument.Bookmarks("Text6").Range.Text
    .Cells(9, 2).Value = ActiveDocument.Bookmarks("Text9").Range.Text
End With
MsgBox "Excel file will now be closed..."
xlWB.Close          ' prompts to save changes
xlApp.Quit           ' close Excel instance
Set xlWB = Nothing
Set xlApp = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,617
Messages
6,186,017
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top