Altering an open excel document

U

umop

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top