PC Review


Reply
Thread Tools Rate Thread

Bypass Workbook_Open event when opening Another WB

 
 
James
Guest
Posts: n/a
 
      8th Apr 2009
Hi, this is what i have so far. I'm trying to open another workbook (oWB) and
read data from multiple sheets, the Populate fields in thisworkbook and close
oWB. oWB will sometimes be opened as read only because it is on a network.
And in the open code of oWB there is a read only check that gives me an
error. I need to open the workbook so the automatic "Open" event doesnt fire
(in oWB) how do i do this?. Thanks for any help!

MyPath = Application.GetOpenFilename(fileFilter:="Microsoft Excel Files
(*.xls), *.xls", Title:="Select File to Open...")
Set oXL = New Excel.Application
Set oWB = oXL.Workbooks.Open(Filename:=MyPath)

Also, will this keep oWB invisible? id like to keep it from poping up on the
screen.
and is it necessary for me to create a new application oXL? I took this from
another program i had that was written in VB from a word application so this
is why i am asking. thanks again!


 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      8th Apr 2009

You don't need to create a new instance of Excel. Just use
EnableEvents to turn off events when opening the workbook.
E.g.,

Application.EnableEvents = False
Set oWB = Application.Workbooks.Open(MyPath)
Application.EnableEvents = True

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Wed, 8 Apr 2009 10:14:01 -0700, James
<(E-Mail Removed)> wrote:

>Hi, this is what i have so far. I'm trying to open another workbook (oWB) and
>read data from multiple sheets, the Populate fields in thisworkbook and close
>oWB. oWB will sometimes be opened as read only because it is on a network.
>And in the open code of oWB there is a read only check that gives me an
>error. I need to open the workbook so the automatic "Open" event doesnt fire
>(in oWB) how do i do this?. Thanks for any help!
>
>MyPath = Application.GetOpenFilename(fileFilter:="Microsoft Excel Files
>(*.xls), *.xls", Title:="Select File to Open...")
>Set oXL = New Excel.Application
>Set oWB = oXL.Workbooks.Open(Filename:=MyPath)
>
>Also, will this keep oWB invisible? id like to keep it from poping up on the
>screen.
>and is it necessary for me to create a new application oXL? I took this from
>another program i had that was written in VB from a word application so this
>is why i am asking. thanks again!
>

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      8th Apr 2009
Chip, I've recently had to change the AutomationSecurity setting to low
before opening workbooks with macros as I'm being asked to enable the macros
when I open them. This change came when I was using Office 2003 when a patch
was pushed.

"Chip Pearson" wrote:

>
> You don't need to create a new instance of Excel. Just use
> EnableEvents to turn off events when opening the workbook.
> E.g.,
>
> Application.EnableEvents = False
> Set oWB = Application.Workbooks.Open(MyPath)
> Application.EnableEvents = True
>
> Cordially,
> Chip Pearson
> Microsoft Most Valuable Professional
> Excel Product Group, 1998 - 2009
> Pearson Software Consulting, LLC
> www.cpearson.com
> (email on web site)
>
>
>
>
> On Wed, 8 Apr 2009 10:14:01 -0700, James
> <(E-Mail Removed)> wrote:
>
> >Hi, this is what i have so far. I'm trying to open another workbook (oWB) and
> >read data from multiple sheets, the Populate fields in thisworkbook and close
> >oWB. oWB will sometimes be opened as read only because it is on a network.
> >And in the open code of oWB there is a read only check that gives me an
> >error. I need to open the workbook so the automatic "Open" event doesnt fire
> >(in oWB) how do i do this?. Thanks for any help!
> >
> >MyPath = Application.GetOpenFilename(fileFilter:="Microsoft Excel Files
> >(*.xls), *.xls", Title:="Select File to Open...")
> >Set oXL = New Excel.Application
> >Set oWB = oXL.Workbooks.Open(Filename:=MyPath)
> >
> >Also, will this keep oWB invisible? id like to keep it from poping up on the
> >screen.
> >and is it necessary for me to create a new application oXL? I took this from
> >another program i had that was written in VB from a word application so this
> >is why i am asking. thanks again!
> >

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook_open Event Hassan Microsoft Excel Programming 3 7th Jul 2008 12:37 PM
WORKBOOK_OPEN event =?Utf-8?B?REtT?= Microsoft Excel Programming 6 22nd Sep 2006 10:40 PM
Bypass Workbook_Open when opening a workbook with VBA Paul Microsoft Excel Programming 2 14th Feb 2005 07:37 AM
RE: WorkBook_Open Event Squid Microsoft Excel Programming 1 8th Feb 2004 02:45 AM
OnTime event not firing in Workbook_Open event procedure GingerTommy Microsoft Excel Programming 0 24th Sep 2003 03:18 PM


Features
 

Advertising
 

Newsgroups
 


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