Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does anyone have any suggestions on how to run a macro when I open a file?
For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank everyone very much for suggestions
I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
i think you are confused. workbook_open is an event. the macro will run automaticly when the workbook is opened. regards FSt1 "Eric" wrote: Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Eric
Private Sub Workbook_Open() will automatically run opening a Workbook. Macros must be enabled of course. The code shown previously must reside in the ThisWorkbook Module. -- Regards Dave Hawley www.ozgrid.com "Eric" wrote in message ... Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
afterthought the macro would go in the file that you want the code to run at workbook open. goes in the thisWorkbook module. Regards FSt1 "Eric" wrote: Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Eric" wrote in message ... Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric You could use this. It is automatically run with the workbook is opened. You may also have to set this if you are opening the workbook from another workbook macro... ActiveWorkbook.RunAutoMacros xlAutoOpen Sub Auto_Open() code here End Sub Mike |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank everyone very much for suggestions
When I tried it on a blank worksheet, it works, but when I insert following codes into my existing file.xls, it cannot run at all. When I open file.xls, it will request confirmation to activate macro and to update all links, after that, it stops without performing anything. Do you have any suggestions what cause it not running? Thanks in advance for any suggestions Eric "FSt1" wrote: hi afterthought the macro would go in the file that you want the code to run at workbook open. goes in the thisWorkbook module. Regards FSt1 "Eric" wrote: Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank everyone very much for suggestions
When I insert following codes into my existing file.xls, it cannot run at all. When I open file.xls, it will request confirmation to activate macro and to update all links, after that, it stops without performing anything. Do you have any suggestions what cause it not running? Thanks in advance for any suggestions Eric Sub Auto_Open() nameofmacro End Sub "Mike" wrote: "Eric" wrote in message ... Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric You could use this. It is automatically run with the workbook is opened. You may also have to set this if you are opening the workbook from another workbook macro... ActiveWorkbook.RunAutoMacros xlAutoOpen Sub Auto_Open() code here End Sub Mike . |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Eric" wrote in message ... Thank everyone very much for suggestions When I insert following codes into my existing file.xls, it cannot run at all. When I open file.xls, it will request confirmation to activate macro and to update all links, after that, it stops without performing anything. Do you have any suggestions what cause it not running? Thanks in advance for any suggestions Eric Sub Auto_Open() nameofmacro End Sub "Mike" wrote: "Eric" wrote in message ... Thank everyone very much for suggestions I would like to trigger a macro by opening a file.xls, but in your coding, I require to run Workbook_Open macro after a file.xls is opened. Does anyone have any suggestions on how to trigger macro automatically by opening file.xls, where the macro is inside the file.xls. Does anyone have any suggestions? Thanks in advance for any suggestions Eric "FSt1" wrote: hi something like this might work........ Private Sub Workbook_Open() If Time "9:00 AM" And Time < "10:00 AM" Then call ASpecificMacro Else MsgBox "current time out of range. terminating macro run." end if end sub this would go in the workbook module. regards FSt1 "Eric" wrote: Does anyone have any suggestions on how to run a macro when I open a file? For example, I would like to run a specific macro within file.xls, if current time is between 9 am and 10 am, otherwise, don't run this macro. Does anyone have any suggestions on how to do it? I am using XP with SP3 and Office 2003. Thanks in advance for any suggestions Eric You could use this. It is automatically run with the workbook is opened. You may also have to set this if you are opening the workbook from another workbook macro... ActiveWorkbook.RunAutoMacros xlAutoOpen Sub Auto_Open() code here End Sub Mike . You may need to create a digital signature for yourself and then add it from the tools menu in vba. Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro for Opening Reuters, Opening Excel File, Closing Excel File | Excel Programming | |||
how to run macro on opening of file | Excel Programming | |||
Can a macro be run on opening the file? | Excel Discussion (Misc queries) | |||
File opening via Macro with varying file name | Excel Programming |