Open an excel 2007 file WITH hyperlinks in Windows cmd.exe RRS feed

  • Question

  • Hi,

    I would like to create a script that opens an excel file (.bat precisely). My problem is that this excel file has hyperlinks inside, and I have to make these hyperlinks efficient, in order to actualize my file.

    In excel 2007, there is always a window that opens and ask whether we want those hyperlinks or not. I would like to automatically say, when it opens, that it opens with hyperlinks included.

    Could you help me, please? I have been researching about it and didn't find anything :-)

    Monday, August 4, 2014 11:41 AM


  • Hi,

    To open the hyperlinks in a workbook when it is opened, you could make the workbook to be a macro enabled workbook (*.xlsm file), then you could add a macro in the workbook with Workbook.Open Event, which occurs when the workbook is opened.

    You could resort to Hyperlink.Follow Method in Excel Object Model to open the hyperlink.

    Here is a sample for your reference. In my sample, it will open all the hyperlinks in the sheet1 when the workbook opens. You could automatically open the workbook in your script. But don't forget to enable the macro manually after you open the workbook, which cannot be done automatically.

    Private Sub Workbook_Open()
    Dim ws As Worksheet
    Dim hl As Hyperlink
    Set ws = ActiveWorkbook.Sheets(1)
    For Each hl In ws.Hyperlinks
        hl.Follow NewWindow:=False, AddHistory:=True
    End Sub

    If you want to open the hyperlinks from the script, I'm not sure which script you are using, would you mind sharing your sample code?

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 5, 2014 5:09 AM