Solved

Display "Wait" while file is being loaded by VBA

Posted on 2013-12-02
11
580 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 4

Expert Comment

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

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 33

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 33

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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…

856 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