View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Altering an open excel document

Maybe try using GetObject .

NickHK

"umop" wrote in message
oups.com...
I have an excel document that I sometimes work on manually, and
sometimes have outlook alter via:

Dim xl As New Excel.Application
Dim xlwbook As Excel.Workbook
Set xlwbook = xl.Workbooks.Open("C:\...\spreadsheet.xls")
... etc

The problem:
This works fine, but currently, when I have outlook edit the
spreadsheet, I have to close it so that there aren't two instances
open (to create conflicts, forget to save work, etc).

The question:
Is there a way of editing the open spreadsheet if it is currently
open, and otherwise, open a new instance (as I'm currently doing)?

so:

Dim xl As New Excel.Application
Dim xlwbook As Excel.Workbook
if workbookIsCurrentlyOpen("C:\...\spreadsheet.xls") then '
pseudocode
Set xlwbook = referenceExistingInstanceOf("C:\...
\spreadsheet.xls") ' pseudocode
else
Set xlwbook = xl.Workbooks.Open("C:\...\spreadsheet.xls")
end if
... etc

Thanks,
Eric