Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Using Container in Auto open macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pukya78@gmail.com - 09 Nov 2006 11:23 GMT
Hi,
I have an excel file which is embedded in some application. I ahve a
macro written in the excel file. I want the macro to run automatically
as soon as I open the excel sheet. For this I used the Workbook_Open
macro. But inside this macro if I try to call the Container method, I
am getting an error.

<code>
Private Sub Workbook_Open()
Dim x As Object
Worksheets("Sheet1").Activate
Set x = ThisWorkbook.Container
End Sub

</code>

But, instead of using the Workbook_Open macro, I use some other macro,
say macro1, and then run that macro manucally after opening the excel
sheet, I get no error. Does anyone have any idea why it does not work
when I use Workbook_Open macro? I want the macro to run as soon as I
open the excel sheet.

<code>

Private Sub macro1()
Dim x As Object
Worksheets("Sheet1").Activate
Set x = ThisWorkbook.Container
End Sub

</code>

Regards,
AA
Jean-Guy Marcil - 09 Nov 2006 19:21 GMT
pukya78@gmail.com was telling us:
pukya78@gmail.com nous racontait que :

> Hi,
> I have an excel file which is embedded in some application. I ahve a
> macro written in the excel file. I want the macro to run automatically
> as soon as I open the excel sheet. For this I used the Workbook_Open
> macro. But inside this macro if I try to call the Container method, I
> am getting an error.

Maybe the Workbook opens too slow for the code. So, when it hits the "Set
x... " statement Excel does not yet know "what" the Container is?

Have you tried with a Delay (OnTime or Pause)?

But, really, maybe you should ask in an Excel group.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.