LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Disabling Events

I have a VBA procedure that runs in Outlook. It opens an Excel
spreadsheet (A.xls), reads some data from sheet "B" and then closes
A.xls There are macros in A.xls and in my Personal.xls that will
execute on open. I do not want that to happen when A.xls is opened
from Outlook. I have tried using the EventsEnable = False (which works
when one spreadsheet is opening another), but that does not seem to
work here. The problem is not the macros in A.xls but the macros in
Personal.xls. One of those macros does a lot of fetching from yet
other spreadsheets, build menus, and other stuff. If that macro
executes, it seems to get confused and generate a compiler error. The
Outlook procedure still runs correctly to completion but I would like
to eliminate the error. Any help would be appreciated. The relevant
VBA code (in Outlook) is below.

Thanks


'
' define Excel types
'
Dim xLApp As Excel.Application
Dim xLBook As Excel.Workbook
Dim xLSheet As Excel.Worksheet
'
' traditional definitions
'
Dim xLPath As String
Dim xLFileName As String
'
' define location and filename of target spreadsheet
'
xLPath = "D:\TestArea"
xLFileName = "A.xls"
'
' define application object
' set events to false (so macros do not run on startup)
'
Set xLApp = CreateObject("Excel.Application")
xLApp.EnableEvents = False
'
' open target spreadsheet
' define target worksheet
'
xLApp.Workbooks.Open FileName:=xLPath + "\" + xLFileName
Set xLSheet = xLApp.Workbooks(xLFileName).Worksheets("B")
'
' perform spreadsheet operations
'
... do various things ...

'
' close spreadsheet
' misc housekeeping
'
xLApp.Workbooks(xLFileName).Close


---
Message posted from http://www.ExcelForum.com/

 
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
Disabling formula Mel D Excel Discussion (Misc queries) 2 May 25th 08 10:54 PM
Disabling the cut function? Tim G. Excel Discussion (Misc queries) 3 September 27th 06 05:01 PM
Disabling Commands Loomah Excel Programming 1 January 16th 04 12:52 PM
Disabling Screensaver Jeff Armstrong Excel Programming 1 December 19th 03 07:13 PM
Auto_Open disabling Tritan Excel Programming 6 July 22nd 03 11:48 AM


All times are GMT +1. The time now is 06:50 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"