Solved

Display "Wait" while file is being loaded by VBA

Posted on 2013-12-02
11
569 Views
Last Modified: 2013-12-02
My code opens a file when a particular cell is selected. This causes excel to pause for a few seconds. I would like some code to create a text box, display the message in the centre of the window and then delete it as soon as the file is opened. I do not want to do this with a message box or a modal userform.
0
Comment
Question by:Saqib Husain, Syed
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 4

Expert Comment

by:andrew_man
ID: 39689744
This is a good question, but I seem to create a text box either to use message box or userform.

Do we have another choice?

Can you give us an example?
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39689747
How about a modeless userform?
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39689758
Nope to both.

I would like to have this piece of code which I can simply copy and paste to another place instead of having to create userforms as well. Msgbox needs user intervention.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 4

Expert Comment

by:andrew_man
ID: 39689761
I think msgbox can no user intervention
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 39689768
How about using the Message/Status Bar at the bottom of the screen?

Alternatively, have a section in the file (separate tab maybe?) with the required message and the script goes to this tab, switches off screen updating while performing what is required and then switches Screen Update back on to go back to where the user initiated the script.

Thanks
Rob H
0
 
LVL 4

Expert Comment

by:andrew_man
ID: 39689774
Dear ssaqibh,

The Rob mentioned status bar, the status bar is a choice for your case!

Andrew Man from Hong Kong
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39689782
andrew_man, you have to click on OK to get rid of the message box.

Rob, bottom of the screen is too small. I would like large text. Just a text box created and then deleted is what I want.

I could do it myself but I wanted to let someone get the points and I get the product.
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 39689789
Scrub my second option (separate tab), this would mean incorporating that tab in all files in much the same way as incorporating a UserForm which you don't want to do.

Thanks
Rob
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 39689796
You could use something like this:

   Dim tb                          As TextBox
   With ActiveCell
      Set tb = .parent.TextBoxes.Add(.Left, .Top, 100, 60)
   End With
   With tb
      .Text = "Please wait..."
      .Font.Size = 40
      .AutoSize = True

   End With
   Workbooks.Open "..."
   tb.Delete

Open in new window

0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 39689831
Sub CreateTextBox()
    
    ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 262.5, 157.5, 384, _
        103).Select
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
        "Please wait while required file opens!"
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 38). _
        ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter
    End With
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 38).Font
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.ObjectThemeColor = msoThemeColorDark1
        .Fill.ForeColor.TintAndShade = 0
        .Fill.ForeColor.Brightness = 0
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 36
        .Name = "+mn-lt"
    End With
    Range("A1").Select
    
'    ActiveSheet.DrawingObjects.Select
'    Selection.Delete

Open in new window


Recorded in Excel 2010 and then tweaked.
0
 
LVL 43

Author Closing Comment

by:Saqib Husain, Syed
ID: 39689844
Great, thanks.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA question, how many data set exists in the sheet 14 59
Excel Cell Total 3 22
Excel - conditional formatting on several columns 9 37
Excel VBA - Constants 4 16
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question