ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm Initialize Problem (https://www.excelbanter.com/excel-programming/397050-userform-initialize-problem.html)

DeathSurfer

UserForm Initialize Problem
 
Duuuuudes:

Is there a way to check if a userform, created with vba, running inside of
Excel 03' is visible without the userforms initialize event running?

Thanks.

joel

UserForm Initialize Problem
 
use this macro

sub test()
'You can initialize variable here
userform1.listbox1.text = "Hello"
userform1.show
end sub

"DeathSurfer" wrote:

Duuuuudes:

Is there a way to check if a userform, created with vba, running inside of
Excel 03' is visible without the userforms initialize event running?

Thanks.


DeathSurfer

UserForm Initialize Problem
 
thanks for the reply Joel but I need to know if I can check a form's
visibility status without the initialize event running on the form. I guess
this can't be done because the form has to load into memory before it can
check the visibility status.

"Joel" wrote:

use this macro

sub test()
'You can initialize variable here
userform1.listbox1.text = "Hello"
userform1.show
end sub

"DeathSurfer" wrote:

Duuuuudes:

Is there a way to check if a userform, created with vba, running inside of
Excel 03' is visible without the userforms initialize event running?

Thanks.


Tom Ogilvy

UserForm Initialize Problem
 
You can check if it is loaded, but if you refer to it, it gets loaded.

A workaround would be to use the findwindow API function.


Something like:

Sub CheckForm()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "MyUserform Caption")
If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If
UserForm1.Show vbModeless
hWnd = FindWindow(vbNullString, "MyUserform Caption")

If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If

End Sub

The above code obviously loads the userform (and fires the initialize
event), but it is just to demonstrate usage.

--
Regards,
Tom Ogilvy





"DeathSurfer" wrote:

Duuuuudes:

Is there a way to check if a userform, created with vba, running inside of
Excel 03' is visible without the userforms initialize event running?

Thanks.


DeathSurfer

UserForm Initialize Problem
 
Thanks Dude.



"Tom Ogilvy" wrote:

You can check if it is loaded, but if you refer to it, it gets loaded.

A workaround would be to use the findwindow API function.


Something like:

Sub CheckForm()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "MyUserform Caption")
If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If
UserForm1.Show vbModeless
hWnd = FindWindow(vbNullString, "MyUserform Caption")

If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If

End Sub

The above code obviously loads the userform (and fires the initialize
event), but it is just to demonstrate usage.

--
Regards,
Tom Ogilvy





"DeathSurfer" wrote:

Duuuuudes:

Is there a way to check if a userform, created with vba, running inside of
Excel 03' is visible without the userforms initialize event running?

Thanks.



All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com