Check opening excel workbook

Started by tlpd, April 08, 2010, 01:01:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tlpd

I have a Visio file, when this file is opened it will call a VBA script to open EXCEL file for editing data. At this time, if user close the Visio file then open it again, it will create a new excel workbook in [Read-Only] mode (because the previous excel file has not been closed). I have some questions related to this problem and i wonder if someone could give me some hints

1. How to check if the workbook is opening. i need to active that excel object again or create new if it is not being opened
2. In case i have an excel object, when i choose to close the Visio file, i want the excel file is closed too

The below is the code i used to open the excel workbook from visio file

set appExcel = CreateObject("excel.application")
appExcel.Visible = true

set xlBook = appExcel.WorkBooks.Open("...some path...")
set xlSheet = xlBook.WorkSheets("Sheetname")


Thank you very much in advance.