+ Reply to Thread
Results 1 to 5 of 5

Forcing a specific Worksheet to be visible behind a MSGBOX

  1. #1
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Forcing a specific Worksheet to be visible behind a MSGBOX

    In my application that involves multiple workbooks, I am trying to arrange for a certain worksheet (Enrollment) of a certain workbook (CampWorkbook…although this is a variable of type WORKBOOK and has the actual workbook name assigned to it much earlier in the application ) to be visible behind a message box that I issue. I want this so that the user can respond in the message box based on what he/she sees behind the message box. The desired workbook/worksheet is opened and neither the workbook nor the worksheet are hidden, merely concealed by overlapping worksheets. My code to do this seems to work sometimes but not at other times. I run the application on two machines and it seems to always work on one of them (the development/test machine). It works intermittently on the other (the production machine!). I've not been able to isolate the cause of the failure. The germane segments of the code are below. One clue might be that putting a break point on the statement:

    Please Login or Register  to view this content.
    (which is ahead of the msgbox statement) and when the break is encounter, clicking F8 to step forward through this segment of code seems to make the desired positioning work. Obviously this is not an acceptable solution!

    Can someone help me please? Perhaps there is a preferred/standard technique to force the visibility of a certain worksheet other than using “ACTIVATE” ? I've read a bit about the VISIBLE property, but despite its name, I haven't concluded that its what I need....am I wrong?

    Below are segments of the code involved: (You'll see that I have deleted portions of the code that don't seem relevant to my issue.)

    Please Login or Register  to view this content.

    Thanks.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Forcing a specific Worksheet to be visible behind a MSGBOX

    Setting .Visible=True would only apply if the sheet was hidden to begin with, which I'm assuming is not the case or it wouldn't be intermittent. I've seen cases where stepping through the debugger causes different behaviors than running normally, but that is usually because of either timing issues or focus issues (where the debug window now has the focus instead of another object), but that's probably not the case either. I've also embarrassed myself on forums more than once by saying that other code or circumstances were not relevant, and then it turned out they were. That may not be the case here either, but I don't see anything that would cause an intermittent or machine-related problem. Questions to aid in your research: When the enrollment sheet is not displayed, then what sheet is? Is it consistent? Since putting a debug stop before the msgbox doesn't help, try putting it after. Maybe that will reveal different results.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Re: Forcing a specific Worksheet to be visible behind a MSGBOX

    Natefarm: Thanks for you insights and hypotheses. I will try your suggestion and research aid. Since my post, I had already thought of timing issues that you mentioned and have put an APPLICATION.WAIT statement between the .ACTIVATE and the MSGBOX statement. I did this on the development machine just to verify the syntax and that it didn't do something undesirable. Everything worked fine...but that means little until I move the change to the production machine. I won't have access to the production machine until Tuesday. If the APPLICATION.WAIT doesn't help, I'll pin down what sheet is showing to see if that is a clue. My (poor) memory is that whatever sheet WAS showing was incompletely painted....but I'll do the test. Thanks again. Short of offering a definite clue, problem determination aids are always beneficial.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Forcing a specific Worksheet to be visible behind a MSGBOX

    Given a range object, you could use code like this to make it visible.


    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Re: Forcing a specific Worksheet to be visible behind a MSGBOX

    Natefarm and mikerickson: Thanks for helping me.

    I got a chance to test the
    Please Login or Register  to view this content.
    statement on the premise that there was some asynchronicity going on with the Windows putting up the MsgBox. That must have been the case. I put a 1 second wait time and the worksheet behind the MSGBOX was precisely what I wanted.

    Mike: Thanks for your suggestion. I don't recognize the code sequence you suggested, but will analyze it to put it in my arsenal of coding tricks.

    Thanks again to both of you.
    Last edited by DanBlum; 01-20-2015 at 03:35 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Display msgbox when specific text entered in specific range
    By Ali_Riza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2012, 08:05 AM
  2. MsgBox remains visible after OK
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2012, 10:59 AM
  3. Check if Specific Visible Worksheet Exists
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-24-2011, 11:35 AM
  4. [SOLVED] Forcing a specific date format
    By DianeMcP in forum Excel - New Users/Basics
    Replies: 10
    Last Post: 10-27-2005, 12:05 PM
  5. [SOLVED] Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.
    By Oscar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-21-2005, 06:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1