Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    On open ? (2000)

    I have some code placed in the 'On activate' code of a workbook... however, what i think i need is something like on open.

    Looking at the choices for the Worksheet that i can see, i see :-

    Activate
    BeforeDoubleClick
    BeforeRightClick
    Calculate
    Change
    Deactivate
    FollowHyperlink
    PivotTableupdate
    SelectionChange

    What i need to do, is the run the code when the workbook is open. just the once. it doesn't need to be called again.. It copies some text into the workbook from another..
    Where the Activate code, will only fire when you selected the worksheet, not when its just opened and its already on the right tab. So to get my code to work, i have to click another tab, and then click back ! Duh!

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

    Re: On open ? (2000)

    You need to distinguish between a workbook and a worksheet (workbook = .xls file, can contain many worksheets).

    The events you mention are all worksheet events; you want a workbook event. Double click ThisWorkbook (in the Project Explorer in the Visual Basic Editor). Select Workbook from the Object dropdown list in the upper left corner of the ThisWorkbook code module window. You'll see

    Private Sub Workbook_Open()

    End Sub

    Code you write here will be executed when the workbook is opened.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: On open ? (2000)

    ah,,, yep found it Hans.. thanks.

    copied the code over, and works fine.

    <img src=/S/burga.gif border=0 alt=burga width=40 height=15>

Posting Permissions

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