![]() |
Altering an open excel document
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 |
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 |
All times are GMT +1. The time now is 07:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com