+ Reply to Thread
Results 1 to 4 of 4

Workbook Open Event not triggering

  1. #1
    Mike Jerakis
    Guest

    Workbook Open Event not triggering

    I've got a file where the Sub Workbook_Open() code will not run if the file
    is opened when Excel is not already open, i.e. opened from Explorer or
    directly from an e-mail when Excel is not running. However, it runs
    perfectly fine if Excel is already running, regardless of initiation method.
    Any ideas?

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167
    Hmmm. I have an instance where the "workbook.open" will not open the file no matter what is active or not. I have been reading this forum for two hours and have had no luck.
    (Excel 2003 on Win XP)
    Not trying to hijack your thread, but maybe we can get two for one in here.

    My code:
    Sub Save_As()
    '
    ' Save_As Macro
    ' Macro recorded 1/3/2006 by rstanich
    '
    ' Keyboard Shortcut: Ctrl+x
    '
    Dim sDcode As String 'Date Code as String
    Dim sScode As String 'Serial Number Code as String
    Dim sFname1 As String 'File Name of Original file as String
    Dim vFname2 As Variant 'File Name of New file as Variable
    Dim sPath As String 'Path variable

    sPath = ThisWorkbook.path 'Get path of file

    ThisWorkbook.Activate
    Worksheets("Sheet2").Select 'Select Work Sheet 2
    sDcode = Range("D2").Value 'Select Cell D2 on Sheet 2
    sScode = Range("C2").Value 'Select Cell C2 on Sheet 2
    sFname1 = sPath & "\" & "0020-48183-fir_Cal-Precision.xls" 'Set File Name of Original file
    vFname2 = sPath & "\" & "0020-48183-fir_Cal-Precision-" & sDcode & "-" & sScode & ".xls" 'Set new file name

    'Create new file name begin
    'Check if exists, exit if exists
    ActiveWorkbook.SaveAs Filename:=vFname2, FileFormat:=xlNormal 'Self checks for existing file
    ThisWorkbook.Activate
    'Application.Workbooks.Open Filename:=vFname2

    ActiveWorkbook.Close SaveChanges:=False 'Close new file
    'Open original file
    Workbooks.Open Filename:=sFname1

    End Sub

    Remember kids, I am not Tom or Chip, so be gentle with my coding

    Regards

    Rick
    Last edited by Rick_Stanich; 01-03-2006 at 04:25 PM.

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167
    More info from a new post.
    http://www.excelforum.com/showthread...=1#post1441737
    Regards

    Rick
    Win10, Office 365

  4. #4
    Mike Jerakis
    Guest

    RE: Workbook Open Event not triggering

    Sorry Rick, I've solved my problem -- sort of.

    Seems that my code was somehow bombing. One of my modules was not compiling
    correctly and therefore kept ALL of the modules from compiling. It had to do
    with a removed reference that I did not want to be part of the file that I
    distributed to others. However, by removing the reference the code was no
    longer compiling, but oddly enough only doing it that way when Excel was not
    already open. If Excel was open, all the modules compiled and ran fine,
    except for the "bad" one, obviously.

    This does not sound like your initial problem, but may help that other post
    you linked here.

    "Mike Jerakis" wrote:

    > I've got a file where the Sub Workbook_Open() code will not run if the file
    > is opened when Excel is not already open, i.e. opened from Explorer or
    > directly from an e-mail when Excel is not running. However, it runs
    > perfectly fine if Excel is already running, regardless of initiation method.
    > Any ideas?


+ 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