Solved

Display "Wait" while file is being loaded by VBA

Posted on 2013-12-02
11
537 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 31

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 31

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 31

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

757 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

22 Experts available now in Live!

Get 1:1 Help Now