Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Birmingham, West Midlands, United Kingdom
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    run macro on file | open (xl2ksp3)

    Should know this, but don't. But will when someone has told me....
    I want the following code to run when I click a hyperlink from another workbook, which points to a cell in the 'target' workbook (which it opens if necessary):

    Sub HideWebToolbar()
    Application.CommandBars("Web").Visible = False
    End Sub

    Where do I put this code in the target workbook?

    Thanks in advance

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: run macro on file | open (xl2ksp3)

    Open the target workbook.
    Acitvate the Visual Basic Editor (Alt+F11)
    Double click ThisWorkbook in the Project Explorer (the treeview on the left hand side)
    Select Workbook from the Object dropdown in the upper left corner of the module window.
    Make the code look like this:

    Private Sub Workbook_Open()
    Application.CommandBars("Web").Visible = False
    End Sub

    Alternatively, copy your HideWebToolbar into a standard module (the type you create by selecting Insert | Module) and call it from the Workbook_Open event procedure:

    Private Sub Workbook_Open()
    HideWebToolbar
    End Sub

    The Workbook_Open event procedure will be run automatically when the workbook is opened (and if macros aren't disabled).

  3. #3
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Birmingham, West Midlands, United Kingdom
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: run macro on file | open (xl2ksp3)

    Thank you, Hans, I thought you might be lurking not more than 7 minutes away!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •