PDA

View Full Version : Checking to see if other sheets are open



wildpianist
10-31-2007, 01:48 PM
Hello Sorry to be a pain again but you are just so helpful :giggle

What I need to do is when I open my excel file I would like it to check to see if any other excel files are open in that instance of Excel (where it shows under Windows -> 1. 2. 3. etc the name of the worksheets open)

If there are other worksheets open in that same instance I would like it to then re-open an NEW instance of excel and run seperately from the other instance.

:)

You've all been most kind and helpful, even though I am annoying and dont post any workbooks on here... yet.... I will be soon :)

Norie
10-31-2007, 01:54 PM
Worksheets 'open'?

Perhaps you mean workbooks?

Also how are you opening this file and why do you need the seperate instance?

wildpianist
10-31-2007, 02:21 PM
Sorry this is me not being clear again! lol

Say I had an xls file open say Spreadsheet.xls

Then I went File -> Open

and then opened another file called Spreadsheet2.xls

They would both be opened in the same Excel Instance (being able to flick Ctrl-F6) to see both files

My file I want to open needs to be opened in a new instance as I when I activate some code by clicking on my OK button on my userform it sometimes will try and write the text in the cells of another spreadsheet hence if its in its own instance there isn't much chance of that happening.

:P

figment
10-31-2007, 02:41 PM
the better option would be to look at the code you have and fix it so that it dosn't try to wright in the wrong workbook. i would be willing to help you with this if you like, but opening to a new instance just seems like a work around, apposed to fixing the problem.

wildpianist
10-31-2007, 02:47 PM
I see your point :yes

I did have it so that the code actually hid excel only showing the userform so the user had no other option to open a new instance themselves lol

:content:

Bob Phillips
10-31-2007, 03:45 PM
A new instance is not a good idea (memory hogging).

Hiding Exel is not a good ifdae IMO.

So what exactly is the problem?

wildpianist
10-31-2007, 05:10 PM
I guess there isn't a problem as such its just when I happen to be in another workbook sometimes and when I click the code to write to Sheet2 of the spreadsheet it should be writing to it will write to the active spreadsheet instead (a completely random spreadsheet)

the code to bring Sheet2 active is:


ActiveWorkbook.Sheets("Sheet2").Activate


As I said sometimes it will write into the cells of a completely irrelevant spreadsheet

:(

Bob Phillips
11-01-2007, 01:19 AM
So qualify the code with the details of the target workbook and worksheet.