Solved

Display "Wait" while file is being loaded by VBA

Posted on 2013-12-02
11
553 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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 …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now