Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How to run a macro by opening a file?


"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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to run a macro by opening a file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How to run a macro by opening a file?


"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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for Opening Reuters, Opening Excel File, Closing Excel File Tsp245 Excel Programming 2 August 14th 08 07:24 PM
how to run macro on opening of file Hassan Excel Programming 3 July 24th 08 08:34 AM
Can a macro be run on opening the file? Cortez Excel Discussion (Misc queries) 3 March 8th 07 08:34 PM
File opening via Macro with varying file name TomFish79 Excel Programming 3 August 15th 05 02:32 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"