+ Reply to Thread
Results 1 to 5 of 5

On Error run Private Sub Workbook_Open() <-- is this possible?

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    On Error run Private Sub Workbook_Open() <-- is this possible?

    Hi guys and gals,

    as in the topic : On Error run Private Sub Workbook_Open() <-- is this possible?
    Thanks for any reply!
    Please click the * below if this helps

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: On Error run Private Sub Workbook_Open() <-- is this possible?

    Private Sub Workbook_Open() will only execute when you open your workbook. You can achieve this by writing another sub routine like Private Sub MyCode() where you can place the code of workbook_open by copying the code between Private Sub Workbook_Open() and End Sub lines and placing it between the lines Private Sub MyCode() and End Sub. Then you can call Mycode if an error occurs in your another sub routine.

    Like this.....
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: On Error run Private Sub Workbook_Open() <-- is this possible?

    I was afraid so....
    Thanks for your feedback!

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,280

    Re: On Error run Private Sub Workbook_Open() <-- is this possible?

    That's not correct. Workbook_Open is a routine like any other. As it has Private scope you have to use Run to call it but you can't do it in one line as an On Error statement - you would have to have a goto statement and run it from there:
    Please Login or Register  to view this content.
    for example.

    Having said that, if you want to call the same code from two locations, you should put it into a separate routine and call that from both locations.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: On Error run Private Sub Workbook_Open() <-- is this possible?

    Hi Rory,

    awesome, thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Private sub workbook_open code running workbook_open code from other project
    By marshall_massive in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2013, 06:07 PM
  2. [SOLVED] Help with a Private Sub Workbook_Open
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-26-2013, 02:59 PM
  3. [SOLVED] Private Sub Workbook_Open() & Updating of Links
    By Henk Stander in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 06:42 AM
  4. message box:Private Sub Workbook_Open()
    By arnab0711 in forum Excel General
    Replies: 2
    Last Post: 02-23-2010, 08:59 AM
  5. Explain - Private Sub Workbook_Open()
    By hedge in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2009, 06:55 PM

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