Creating hyperlink from Excel FlowChart to MS Word

2019-07-16 04:07发布

问题:

I am building a flowchart in MS Excel 2007. It's for a work flow. I want to be able to reference a word document which has detailed instructions about each step in the flow chart.

At each section of the flow chart, I want to create a hyperlink/button that the user can click on and open up to that specific portion (heading) of the word document. I've tried to create a shape (rectangle) and set a hyperlink to the document. That works fine, but it just opens the document at the beginning. I want the rectangle button to open at a specific heading. I am not sure if you can hyperlink this way. If not, I'm think I need to create a button control. I'm not sure if a button control can do this either.

Can anyone suggest

1) a way to hyperlink to a heading, and if not,

2) maybe a suggestion on how to use a button control to do this.

Thanks, Mike

回答1:

EDIT: Beaten by VISQL :)

Yes, it is possible to do what you want. Follow these steps.

Open your word document and insert bookmarks at the relevant location. Say, we insert a bookmark called `Mike' at Heading 2.

Paste this code in a module in Excel.

Sub Sample()
    Dim oWordApp As Object, oWordDoc As Object, bMark As Object
    Dim FlName As String

    FlName = "C:\Sample.Docx"

    '~~> Establish an Word application object
    On Error Resume Next
    Set oWordApp = GetObject(, "Word.Application")

    If Err.Number <> 0 Then
        Set oWordApp = CreateObject("Word.Application")
    End If
    Err.Clear
    On Error GoTo 0

    oWordApp.Visible = True

    Set oWordDoc = oWordApp.Documents.Open(FlName)

    Set bMark = oWordDoc.Bookmarks("Mike")

    bMark.Select
End Sub

Right click the button and assign it to the above macro.

And you are done. Next time the user click on that button, the code will open the word document and will go to the relevant bookmark. Repeat the same steps for other buttons.

HTH



回答2:

There might be a way to reference BOOKMARKS you create in the word document, and then specify in your Excels Hyperlink path, the filename of the word document, plus the BOOKMARK within the file. According to this: http://office.microsoft.com/en-us/excel-help/hyperlink-function-HP010062412.aspx

it's possible. Now it's a matter of finding the way to do it using the Excel Hyperlink adding interface.