I can't seem to get the next bit of code working correctly. I used to have it check for certain books but the listing had gotten so long I need to shorten it.
Please Login or Register to view this content.
I can't seem to get the next bit of code working correctly. I used to have it check for certain books but the listing had gotten so long I need to shorten it.
Please Login or Register to view this content.
What's the code meant to do and how is it not working?
If posting code please use code tags, see here.
It's supposed to test for other open workbooks and advise them to close them.
Are you only looking for workbooks with 'OpenBook' in the name?
No I was going to try to use the name of the workbook that runs the code and an IF NOT x then y statement to make sure all other workbooks are giving the correct msgbox to close them.
If you want to check if there are other workbooks than the one the code is in are open use this.
PS What are you doing with iError?Please Login or Register to view this content.
The code is called from another Sub(). It passes along a True/False value then indicates what that main Sub() does next.
It isn't passing iError anywhere.
You're right. Here is how it was called...
I'm not sure what I did wrong...Please Login or Register to view this content.
Try declaring iError in the calling sub and changing openCheck to this.
Which you can call like this.Please Login or Register to view this content.
Please Login or Register to view this content.
That worked wonders. Thank you!
Going back to the original issue... if I have two workbooks open and both contain the new code it causes a problem. Which is why I'm trying to get this code working. So that any workbook open (and they ALL use Ctrl-e to initiate the macro) will not cause a conflict.
Not sure of a solution.
Sorry I'm a little confused.
What exactly are you trying to do?
How does having the code in more than one workbook cause problems?
Like I said, all the workbooks that run the main portion of the macro (this section is only a subfunction to see if any other ones are open) all use Ctrl-e and all do different things. So if I have two workbooks open, Excel may run a different macro then expected. Since not all do the same thing or have similar worksheets, it can err out.
Also since there are muliple sub, functions, etc I can't simply train the braindead people I work with to run the correct one. They have a hard enough time using the simples ones...
Don't use the same shorcut key for the subs.
Why not use buttons to run them instead??
There is only a limited number of key shortcuts available. The braindead people I work with are used to the one key shortcut.
There isn't enough room on the screen to use buttons. The forms take up the whole of the screen and the buttons cannot be on the printed forms in the end result.
How about one button that opens a userform which has buttons on it to run the code?
The button on the worksheet can be set not to print.
There are around 30-40 different spreadsheets, each with a minimum of 1 worksheet to a maximum of 6. The code being run is dependent on the open workbook AND the correct worksheet.
I just don't know (what I'm doing). I'm limited by management from being able to go back and change something that's already serving its purpose.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks