+ Reply to Thread
Results 1 to 5 of 5

OnAction - Adding a command bar

  1. #1
    Registered User
    Join Date
    04-25-2005
    Posts
    99

    OnAction - Adding a command bar

    I'm trying to add a command bar to excel.
    I have the following code in Sub Auto_Open() :

    tmpControl.Caption = "Workbook1"
    tmpControl.OnAction = "Workbook1.xls!RunMacro"
    tmpControl.Tag = "Workbook1"

    I'm wanting to change the tmpControl.OnAction to open the workbook "Workbook1". I know this is set up to run the macro "RunMacro", but I'm not sure how to change it so when I click on the command bar, it will simply just open the workbook.


    Any help is greatly appreciated!!

    Thanks,


    DejaVu

  2. #2
    Registered User
    Join Date
    06-03-2005
    Posts
    2
    OnAction runs macros. Just create a macro that opens the workbook you want and point your OnAction command to that.

    -HT

  3. #3
    Registered User
    Join Date
    04-25-2005
    Posts
    99
    I knew it was for macros, but I was wondering if there was something that I could do to directly open the workbook.

    I have already created a macro that only has a = now() in it

    It solved my problem, but thought it was a cheesy way to do it. I could not think of anything better.



    Thanks,

    DejaVu

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Try This!!!

    Hi another sugestion for you!

    Try this, the first 3 lines turn standard menubars off, the 4th you need to insert your menu bar name and the next 2 lines (which you can repeat) are to assign subs to buttons when the workbook is opened (modify with your names). don't forget the things you turn off (False) in an Auto_open need to be turned back on (True) in your Auto_close

    Hope this helps

    Simon

    Sub Auto_open()

    With Application
    .CommandBars.ActiveMenuBar.Enabled = False
    .CommandBars("Formatting").Visible = False
    .CommandBars("Standard").Visible = False
    .CommandBars("your menubar name").Visible = True
    .CommandBars("your menubar name").Controls("your button name").OnAction = "your sub name"
    .CommandBars("your menubar name").Controls("your button name").OnAction = "your sub name"
    .DisplayFullScreen = False
    .DisplayFormulaBar = False
    .DisplayStatusBar = False
    End With
    End Sub

  5. #5
    Registered User
    Join Date
    04-25-2005
    Posts
    99
    Got it! Thanks for your suggestions... I have the results I was looking for!


    Thanks for the assistance!


    DejaVu

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1