Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default WorkBook Activate event not working

Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default WorkBook Activate event not working

Application.EnableEvent(True)
Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default WorkBook Activate event not working


Don Guillett wrote:
Application.EnableEvent(True)

Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default WorkBook Activate event not working


wrote:
Don Guillett wrote:
Application.EnableEvent(True)

Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.


I am sorry, I did have EnableEvents(True) in my code, it was a typo.
And I am coding in c++, so ActiveWorkbook is a object variable in my
code. It has nothing to do with the predefined reference.
The macro itself that I have defined in the xla file is as follows,

Private Sub App_WorkbookActivate(ByVal Wb As Workbook)

Application.SendKeys ("%C")
Application.Dialogs(xlDialogPrintPreview).Show

Dim currentWindow As Window
For Each currentWindow In Wb.Windows
currentWindow.View = xlPageBreakPreview
Next currentWindow

End Sub

The xla file is in the excel start up folder, so it gets executed when
I open the file from explorer. However, when I try to open the file
from automation, it does not execute the activate event.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default WorkBook Activate event not working

I don't do C++. This is visual basic for applications VBA

--
Don Guillett
SalesAid Software

wrote in message
ups.com...

Don Guillett wrote:
Application.EnableEvent(True)

Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name
is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default WorkBook Activate event not working

I see your deeply engaged with Don in some heavy duty topics, but just for
interest, Addins and files in the xlStart directory are not loaded when Excel
is started programmatically.

--
Regards,
Tom Ogilvy





" wrote:


Don Guillett wrote:
Application.EnableEvent(True)

Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.


  #7   Report Post  
Posted to microsoft.public.excel.programming
ksr ksr is offline
external usenet poster
 
Posts: 4
Default WorkBook Activate event not working

Thanks.
Is there any way I can have this macro execute when excel is started
programatically?


Tom Ogilvy wrote:
I see your deeply engaged with Don in some heavy duty topics, but just for
interest, Addins and files in the xlStart directory are not loaded when Excel
is started programmatically.

--
Regards,
Tom Ogilvy





" wrote:


Don Guillett wrote:
Application.EnableEvent(True)
Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default WorkBook Activate event not working

Sure, in the same code that opens the workbook, open the addin as well.

As an alternative, you can load it as an addin, but opening it should have
the same effect.

--
Regards,
Tom Ogilvy


"ksr" wrote:

Thanks.
Is there any way I can have this macro execute when excel is started
programatically?


Tom Ogilvy wrote:
I see your deeply engaged with Don in some heavy duty topics, but just for
interest, Addins and files in the xlStart directory are not loaded when Excel
is started programmatically.

--
Regards,
Tom Ogilvy





" wrote:


Don Guillett wrote:
Application.EnableEvent(True)
Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default WorkBook Activate event not working

Tom, please feel free to step in and help the OP

--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
I see your deeply engaged with Don in some heavy duty topics, but just for
interest, Addins and files in the xlStart directory are not loaded when
Excel
is started programmatically.

--
Regards,
Tom Ogilvy





" wrote:


Don Guillett wrote:
Application.EnableEvent(True)
Application.EnableEventS=true


Here is one I use with a double_click event to goto a workbook whose
name is
typed in a cell.

Sub GetWorkbook()
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer.
But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.


Thanks for your reply.
The code looks similar, except for
Windows(workbookname & ".xls").Activate
What does the above line of code do?
I am writing in c++ and I am not sure what is the code equivalent to
the above in c++?
I understand Workbook activate is executed when workopen is opened.




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default WorkBook Activate event not working

Activeworkbook is a predefined reference to the workbook that is active. I
wouldn't try setting it to anything.

The fact that you show that code and say that it works in any situation
makes your whole presentation suspect.

Of course Don has already pointed out an additional offending line:
Application.EnableEvent(True)

--
Regards,
Tom Ogilvy


" wrote:

Hello,

I have an excel addin (.xla) file under excel startup folder (ie,
\office11\startup), where I have defined App_WorkbookActivate event.
This macro executes fine when I open the excel file from explorer. But
when I open the file from automation, it does not execute.
The code is as follows,

Application.EnableEvent(True)
ActiveWorkbook = AllWorkbooks.Open("filename")
ActiveWorkbook.RunAutoMacros(3)

Any suggestions would help!

Thankyou.




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
Auto Activate (Window_Open Event) in Personal.xls when another workbook is loaded Nap Excel Programming 7 March 24th 06 09:22 AM
Workbook.Activate / Window.Activate problem Tim[_44_] Excel Programming 3 February 3rd 06 11:38 PM
On activate event SHIPP Excel Programming 5 December 30th 05 04:43 PM
Pasting after Workbook Activate event Michael Malinsky[_2_] Excel Programming 2 June 6th 05 08:01 PM
Activate event Lynn[_3_] Excel Programming 2 September 13th 03 09:30 PM


All times are GMT +1. The time now is 04:06 AM.

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"