Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
192to196
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
192to196
192to196
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

"Bitte warten!" waehrend Makro

"Bitte warten!" waehrend Makro
18.12.2002 19:49:50
Thilo
Hallo,
ich hab ein Makro, das etwas laenger braucht, bis es durchgelaufen ist. Derweil wuerde ich gerne eine kurze Info aufblenden lassen, dass es halt etwas dauert.
Ich hab's mit einer Userform versucht, da ich keinen Button etc. haben will. Das Problem ist, dass nie der Text oder das Bild, dass ich in der Userform eingefuegt habe erscheint, sondern es einfach weiss bleibt waehrend das Makro laeuft.
Wie kann ich das aendern?

11
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Re: "Bitte warten!" waehrend Makro
18.12.2002 20:02:28
Hajo_Zi
Hallo Thilo

Du muß Dein Makro von der Userform aus starten. Siehe Beispiel.

https://www.herber.de/user/thilo.xls

Gruß Hajo

Re: "Bitte warten!" waehrend Makro
18.12.2002 20:05:20
Thilo
Danke fuer das Beispiel.
Ein automatischer Start des Makros geht also nicht?
Re: "Bitte warten!" waehrend Makro
18.12.2002 20:07:59
Hajo_Zi
Hallo Thilo

dann nekommst Du aber nicht die Userform. In dem, Fall mußt Du Dich mit der Statusleiste von Excel begnügen.

Gruß Hajo

Re: "Bitte warten!" waehrend Makro
18.12.2002 20:09:58
Thilo
Nun gut, man kann nicht alles haben :-)

Vielen Dank!

Re: "Bitte warten!" waehrend Makro
18.12.2002 20:17:15
Jessica
Ich habe das ganz schick mit dem Office Assi gelöst:

Private asTitle As String
Private asTitle2 As String
Private asVisible As Boolean
Private oBlase As Balloon
Private rBlase As Balloon

Sub AssistentAuswahlAnzeigenUndWahlAusführen()
With Assistant
.Reduced = True
.Left = 900
.Top = 600
.MoveWhenInTheWay = True
.TipOfDay = True
.Visible = True
.Animation = msoAnimationGreeting
End With
asVisible = Assistant.Visible
asTitle = "Dateneingabe komplett!"
asTitle2 = "Bitte warten!"
Select Case BlaseAnzeigen
Case -1
If oBlase.CheckBoxes(1).Checked = True Then
DokumentSpeichern
Assistant.Animation = msoAnimationSaving
End If
ZweiteBlase
Case -2 'Der Benutzer hat den Dialog abgebrochen
If oBlase.CheckBoxes(1).Checked = True Then
DokumentSpeichern
End If
HappyEnd
End Select
HappyEnd
End Sub

Private Sub DokumentSpeichern()
ActiveWorkbook.Save
End Sub

Private Sub HappyEnd()
Assistant.Visible = asVisible
End
End Sub

Private Function BlaseAnzeigen()
Set oBlase = Assistant.NewBalloon
With oBlase
.Mode = msoModeModal
.BalloonType = msoBalloonTypeButtons
.Icon = msoIconTip
.Heading = asTitle
.Text = "Alle notwendigen Daten sind eingegeben. Wollen Sie die Berechnungen jetzt starten?" & _
" Dieser Vorgang kann einige Zeit in Anspruch nehmen."
.CheckBoxes(1).Text = "Eingegebene Werte speichern"
.Button = msoButtonSetOkCancel
BlaseAnzeigen = .Show
End With
End Function

Sub ZweiteBlase()
oBlase.Close
Blase2Anzeigen
NeueStunde = Hour(Now())
NeueMinute = Minute(Now())
NeueSekunde = Second(Now()) + 2
WarteZeit = TimeSerial(NeueStunde, NeueMinute, NeueSekunde)
Application.Wait WarteZeit
MakroStart
BlaseSchliessen
End Sub

Sub BlaseSchliessen()
rBlase.Close
Assistant.Animation = msoAnimationDisappear
Assistant.Visible = False
End Sub

Private Function Blase2Anzeigen()
Set rBlase = Assistant.NewBalloon
With rBlase
.Mode = msoModeModeless
.BalloonType = msoBalloonTypeButtons
.Icon = msoIconTip
.Heading = asTitle2
.Text = "Die Berechnungen laufen."
.Button = msoButtonSetNone
Blase2Anzeigen = .Show
End With
Assistant.Animation = msoAnimationWorkingAtSomething
End Function

Sub BlaseSchliessen()
rBlase.Close
Assistant.Animation = msoAnimationDisappear
Assistant.Visible = False
End Sub

Gruß,
Jessica

Anzeige
Re: "Bitte warten!" waehrend Makro
18.12.2002 20:17:33
Matthias H.
Also ich habe da eine ganz triviale Lösung:
ein neues Worksheet erstellen, und den Text z.B. "Bitte warten" eintippen (nach Bedarf formatieren: grauer Hintergrund usw.)
dann Dein Makro so ändern:

Sub test()
Sheets("Bittewarten").Select
Application.ScreenUpdating = False
Dein Makro
Sheets("Dein ursprüngliches Worksheet").Select
Application.ScreenUpdating = True
End Sub



Fortschrittsanzeige ?
18.12.2002 20:19:36
andreas e
bin zwar fast schon weg, aber das hört sich an wie eine "Fortschrittsanzeige" !
So was ähnliches war vor einiger zeit mal mit walter heir.

Kleiner denkanstoss wäre:
Der Link dazu: http://j-walk.com/ss/excel/tips/tip34.htm
Displaying a Progress Indicator
A common question among Excel developers is, How can I use a custom dialog box to display the progress of a lengthy macro? This document describes how to create an attractive progress indicator with minimal effort.
Creating the UserForm
Follow the steps below to create the progress indicator UserForm.
Insert a new UserForm and change its Caption to Progress.
Add a Frame control and name it FrameProgress.
Add a Label control inside of the Frame and name it LabelProgress. Remove the Label's caption, and make its background color red.
Add another label (option) to describe what's going on.
Adjust the form and controls so they look like this:

Creating the Event-handler subroutines
The trick here involves running a subroutine automatically when the dialog box is displayed. Since the Initialize event occurs before the dialog box is actually show, you must use the Activate event. Insert the following subroutine in the Code window for the UserForm. This subroutine simply calls the Main subroutine (stored in a VBA module) when the UserForm is displayed.
Private Sub UserForm_activate()
Call Main
End Sub
The Main subroutine is listed below. This demo routine simply inserts random numbers into the active worksheet. As it does so, it changes the width of the Label control and displays the percent completed in the Frame's caption. You will, of course, substitute your own subroutine. And you'll need to figure out how to determine the progress complete.
Sub Main()
' Inserts random numbers on the active worksheet
Dim Counter As Integer
Dim RowMax As Integer, ColMax As Integer
Dim r As Integer, c As Integer
Dim PctDone As Single

If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
Cells.Clear
Application.ScreenUpdating = False
Counter = 1
RowMax = 100
ColMax = 25
For r = 1 To RowMax
For c = 1 To ColMax
Cells(r, c) = Int(Rnd * 1000)
Counter = Counter + 1
Next c
PctDone = Counter / (RowMax * ColMax)
With UserForm1
.FrameProgress.Caption = Format(PctDone, "0%")
.LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
End With
' The DoEvents statement is responsible for the form updating
DoEvents
Next r
Unload UserForm1
End Sub
Creating the start-up subroutine
All that's missing is a subroutine to display the dialog box. Enter the following subroutine in a VBA module.
Sub ShowDialog()
UserForm1.LabelProgress.Width = 0
UserForm1.Show
End Sub
How it works
When you execute the ShowDialog subroutine, the Label object's width is set to 0. Then the Show method of the UserForm1 object displays the dialog box. When the dialog box is displayed, its Activate event is triggered, which executes the Main subroutine. The Main subroutine periodically updates the width of the Label. Notice the DoEvents statement. Without this statement, changes to the Label are not visible. Before the subroutine ends, the last statement unloads the UserForm object.
Caveat
This is definitely a slick technique, but you should be aware that it may slow down your macro a bit due to the extra overhead of updating the progress indicator. In many cases, however, it is not even noticeable.


Ich persönlich habe das mal an nem kleinen bsp. versucht und fand das ganz gut !

Gruß
andreas e
http://www.skripteundaufgaben.de viele kostenlose Downloads und Lösungsansätze zu EXCEL und mehr

Anzeige
Re: "Bitte warten!" waehrend Makro
18.12.2002 20:22:32
andreas e
hallo,
eigentlich ganz simpel , aber doch recht brauchbar - das werde ich mir doch glatt kupfern !
werde es morgen mal testen ! Aber gefällt mir vor allem der kurze code !
Gruß
andreas e
http://www.skripteundaufgaben.de viele kostenlose Downloads und Lösungsansätze zu EXCEL und mehr
Re: "Bitte warten!" waehrend Makro
18.12.2002 20:26:09
Jessica
Ich hab gerade gesehen.. Das Sub BlaseSchliessen ist doppelt.. Davon mußt Du eins löschen, ansonsten nur noch anstatt MakroStart Dein Makro einfügen...
Re: "Bitte warten!" waehrend Makro
18.12.2002 21:33:58
Peter
Hallo !!
Wenn ich Dich richtig verstanden habe, hast Du Dein Makro eigentlich richtig geschrieben, aber das Bild taucht nicht auf, da Excel zu sehr mit dem Makro beschäftigt ist und keine Zeit hat Dein Bild richig anzuzeigen.

Da Dein Makro etwas länger dauert, gehe ich davon aus, dass Du eine Schleife drin hast. Versuche mal am Ende der Schleife folgenden Befehl:

DeineUserform.Repaint

Hoffentlich hilft es Dir.

Bis dann

Peter


Anzeige
Re: "Bitte warten!" waehrend Makro
19.12.2002 00:37:37
Sören Wiechert
Hallo Thilo,

bau einfach an geeigneter Stelle in Dein Makro ein

ein. Damit bekommt das Betriebssystem die Gelegenheit auch andere Dinge als Dein Makro zu erledigen - z.B. die Anzeige von Texten o.ä.

Sören

300 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige