+ Reply to Thread
Results 1 to 5 of 5

Open Event not working

  1. #1
    soundneedle@hotmail.com
    Guest

    Open Event not working

    I have a workbook template that is opened "externally" via code---a
    VB-like form opens the workbook and creates a new worksheet. I don't
    have access to this code, but I do need to add code to the template
    that is triggered either upon open or creating the new sheet. However,
    neither of these events will trigger since the book is being opened via
    external code.

    Is there anyway to work around this? I cannot modify the VB-like form
    or the module that is initially opening the book and creating the new
    worksheet.

    TIA...


  2. #2
    Bob Phillips
    Guest

    Re: Open Event not working

    You could add you code to an Auto_Open sub in a standard code module.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    <soundneedle@hotmail.com> wrote in message
    news:1140565057.481730.249610@z14g2000cwz.googlegroups.com...
    > I have a workbook template that is opened "externally" via code---a
    > VB-like form opens the workbook and creates a new worksheet. I don't
    > have access to this code, but I do need to add code to the template
    > that is triggered either upon open or creating the new sheet. However,
    > neither of these events will trigger since the book is being opened via
    > external code.
    >
    > Is there anyway to work around this? I cannot modify the VB-like form
    > or the module that is initially opening the book and creating the new
    > worksheet.
    >
    > TIA...
    >




  3. #3
    soundneedle@hotmail.com
    Guest

    Re: Open Event not working

    Bob, I've tried adding an auto_open() sub to the workbook_open event,
    but it just gets bypassed. If I open the template by double clicking
    the file, the open event is triggered, but when it's opened through the
    vb-like form, the open event code is bypassed. I tried the code below,
    but I can't get it triggered after "opening" the form via form:

    Sub workbook_open ()
    auto_open()
    End sub

    Sub auto_open()
    '*** hide the scollbars
    With ActiveWindow
    .DisplayVerticalScrollBar = False
    .DisplayHorizontalScrollBar = False
    End With
    End sub


  4. #4
    Kevin Beckham
    Guest

    Re: Open Event not working

    What if the code is added to the Workbook_Open event in ThisWorkbook module ?

    Auto_Open code has to be called specifically if workbook is opened
    programmically
    e.g.
    Set wb = Workbooks.Open "myBook.xls"
    wb.RunAutoMacros xlAutoOpen


    Kevin Beckham

    "soundneedle@hotmail.com" wrote:

    > Bob, I've tried adding an auto_open() sub to the workbook_open event,
    > but it just gets bypassed. If I open the template by double clicking
    > the file, the open event is triggered, but when it's opened through the
    > vb-like form, the open event code is bypassed. I tried the code below,
    > but I can't get it triggered after "opening" the form via form:
    >
    > Sub workbook_open ()
    > auto_open()
    > End sub
    >
    > Sub auto_open()
    > '*** hide the scollbars
    > With ActiveWindow
    > .DisplayVerticalScrollBar = False
    > .DisplayHorizontalScrollBar = False
    > End With
    > End sub
    >
    >


  5. #5
    soundneedle@hotmail.com
    Guest

    Re: Open Event not working

    Kevin, I guess I'm a bit confused. Here's what I've got thus far:

    ThisWorkbook:
    Private Sub Workbook_Open()
    ActiveWorkbook.RunAutoMacros xlAutoOpen
    End Sub

    Module1:
    Sub auto_open()
    MsgBox "event happened"
    End Sub

    This does not work when the workbook is opened via the VB-like form,
    but it does work when you dbl click the template to open. It seems the
    workbook_open event is being bypassed.


+ 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