Hi,
Basically I have a main userform called 'Main' that contains a number of command buttons to run specific macros. I also have another userform called 'Loading' that contains a WebBrowser Control that houses an animated GIF. What I want to achieve is click one of the command buttons on the main form, launch the additional form containing the animated gif and then close this form upon completion of the macro. I have opened both forms as non modal and the loading userform is displayed but there is a white screen where the animated gif should be. I am thinking that it will probably involve DoEvents or Repaint but I'm not quite sure where to include it in the code. Any help would be massively appreciated.
On click event of command button on main form
Private Sub CommandButton1_Click()
Loading.Show vbModeless
Application.Run "Macro1"
Unload Loading
End sub
Code contained within the Loading form:
Private Sub UserForm_Activate()
Call RemoveCaption(Me)
WebBrowser1.Navigate ("C:\Users\B666\Images\31.gif")
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Me.WebBrowser1.Document.body.Scroll = "no"
WebBrowser1.Document.body.Style.Border = "none"
WebBrowser1.Visible = True
Me.Repaint
End Sub
Code in workbook module to remove caption from 2nd userform
Sub RemoveCaption(objForm As Object)
Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As Long
If Val(Application.Version) < 9 Then
mhWndForm = FindWindow("ThunderXFrame", objForm.Caption) 'XL97
Else
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption) 'XL2000+
End If
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndForm
End Sub
Regards,
B666.
Basically I have a main userform called 'Main' that contains a number of command buttons to run specific macros. I also have another userform called 'Loading' that contains a WebBrowser Control that houses an animated GIF. What I want to achieve is click one of the command buttons on the main form, launch the additional form containing the animated gif and then close this form upon completion of the macro. I have opened both forms as non modal and the loading userform is displayed but there is a white screen where the animated gif should be. I am thinking that it will probably involve DoEvents or Repaint but I'm not quite sure where to include it in the code. Any help would be massively appreciated.
On click event of command button on main form
Private Sub CommandButton1_Click()
Loading.Show vbModeless
Application.Run "Macro1"
Unload Loading
End sub
Code contained within the Loading form:
Private Sub UserForm_Activate()
Call RemoveCaption(Me)
WebBrowser1.Navigate ("C:\Users\B666\Images\31.gif")
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Me.WebBrowser1.Document.body.Scroll = "no"
WebBrowser1.Document.body.Style.Border = "none"
WebBrowser1.Visible = True
Me.Repaint
End Sub
Code in workbook module to remove caption from 2nd userform
Sub RemoveCaption(objForm As Object)
Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As Long
If Val(Application.Version) < 9 Then
mhWndForm = FindWindow("ThunderXFrame", objForm.Caption) 'XL97
Else
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption) 'XL2000+
End If
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndForm
End Sub
Regards,
B666.