Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening a seperate window

Status
Not open for further replies.

nurun

Technical User
Apr 26, 2002
8
GB
does anyone know how i can open a window from vba, one that i can move around and have numbers fed to it while running a macro
 
Yes I do.

Provide more detail (which application?), any restrictions (is a userform with large textbox OK?), what has failed, etc.

I will respond.
Steve
 
hi thankyou for your reply.
i am runnung a macro in vba. Its quite a long macro and takes a while. I would like to minimize the window (excel) and monitor its progress in a seperate window (maybe something small in the corner of my screen). I know how to do it in a userform, but i would like to do it in just a blank window similar to a windows window. I hope this makes sense.
Thankyou again
 
The need to minimize Excel and still have a small (child) window present, and always on top (always on top, right?) might be doable.


I run two monitors, so that situation never occurs. I just park Excel on one monitor, let it do what it wants to do, and proceed with another application located on other monitor.

If you aren't running two monitors, let me know, and I will attempt to help you.
 
no steve i have only one screen
:)
ty
 
i need the window to be wherever i want it to be ie anywhere on the screen
being on top is fine too
 
I take that as a "no", since it would be extremely difficult.
 
lol
ok its a no then
so how do i open a window
 
Create a UserForm, leave the name as "UserForm1"
On that form, create a large TextBox, leave the name as "TextBox1"

Change the following TextBox properties:
EnterKeyBehavior to True.
MultiLine to True.

Add this code to userform:
Code:
Option Explicit

Private Sub UserForm_Activate()
StartTime = Now
GenerateTheData
End Sub

Private Sub UserForm_Terminate()
If NextTime > Now Then
        Application.OnTime NextTime, "GenerateTheData", , False
End If
End Sub

Add the following code to a module:
Code:
Option Explicit
Public StartTime, NextTime

Sub GenerateTheData()
    UserForm1.TextBox1.Text = UserForm1.TextBox1.Text & _
    "This data added at " & Time$ & " on " & Date$ & vbLf
    If Now < StartTime + TimeValue(&quot;00:00:10&quot;) Then
        NextTime = Now + TimeValue(&quot;00:00:02&quot;)
        Application.OnTime NextTime, &quot;GenerateTheData&quot;
    Else
        MsgBox &quot;Time Is Up&quot;, , &quot;Routine Will Now End&quot;
        Unload UserForm1
    End If
End Sub

Open the form from the editor, using F5.
It will run until time is up, or until you close the form.
I have tested it, it works for me. Let me know if it fails to demonstrate what you desire.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top