Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook Open Event not triggering
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 vFolder As Variant 'Folder location Dim bOkToSave As Boolean 'True or False Dim sPath As String 'Path variable sPath = ThisWorkbook.path 'Get path of file 'ChDir = sPath 'Change to folder if necessary bOkToSave = False 'Set variable to False 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 & "\" & vFolder & "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 -- Rick_Stanich ------------------------------------------------------------------------ Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957 View this thread: http://www.excelforum.com/showthread...hreadid=497648 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook Open Event not triggering
More info from a new post. http://www.excelforum.com/showthread...=1#post1441737 -- Rick_Stanich I am me ------------------------------------------------------------------------ Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957 View this thread: http://www.excelforum.com/showthread...hreadid=497648 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
workbooks.open without triggering event | Excel Programming | |||
Triggering an event based on reference | Excel Programming | |||
auto-filter change not triggering worksheet_change event | Excel Programming | |||
Triggering click event of a menu in vba | Excel Programming | |||
Triggering click event of a menu in vba | Excel Programming |