![]() |
Run - Time error
I didn't think you were using the Load statement. This, as
you're aware, loads but does not show the UF and lets you manipulate it in the Initialize event. My assumption is that the Show statement both loads and shows a UF. Therefore, the Show statement creates a redundacy (since you have already loaded it) which causes the error. In the Auto_Open code, you can simply state UserForm1.Show and forget the Load statement. Also, remove the Show statement in the Initialize code. This works. Regards, Greg -----Original Message----- I did as you suggested, now my UserForm will not display. I have an auto_open macro which is suppose to open the UserForm when the workbook opens (Load UserForm1) "Greg Wilson" wrote in message ... Simply remove the Show statement. You must already be using the Show statement in a separate module to call the UF. When it initializes, your code tells it to show itself again even though it is already called. This causes the error; however, you must close the UF before the error message can display because the UF has priority. Regards, Greg -----Original Message----- The code below does what I need it to do (displays the current date in a textbox when userform1 opens) but when I close the Userform I get the following error: Run-time error '91': object variable or with block variable not set Private Sub UserForm_Initialize() With UserForm1 .DateTextBox.Text = Format(Date, "dddd dd-mmm- yy") .Show End With End Sub . . |
Run - Time error
Thanks for your help. I thought I had to load the userform.
"Greg Wilson" wrote in message ... I didn't think you were using the Load statement. This, as you're aware, loads but does not show the UF and lets you manipulate it in the Initialize event. My assumption is that the Show statement both loads and shows a UF. Therefore, the Show statement creates a redundacy (since you have already loaded it) which causes the error. In the Auto_Open code, you can simply state UserForm1.Show and forget the Load statement. Also, remove the Show statement in the Initialize code. This works. Regards, Greg -----Original Message----- I did as you suggested, now my UserForm will not display. I have an auto_open macro which is suppose to open the UserForm when the workbook opens (Load UserForm1) "Greg Wilson" wrote in message ... Simply remove the Show statement. You must already be using the Show statement in a separate module to call the UF. When it initializes, your code tells it to show itself again even though it is already called. This causes the error; however, you must close the UF before the error message can display because the UF has priority. Regards, Greg -----Original Message----- The code below does what I need it to do (displays the current date in a textbox when userform1 opens) but when I close the Userform I get the following error: Run-time error '91': object variable or with block variable not set Private Sub UserForm_Initialize() With UserForm1 .DateTextBox.Text = Format(Date, "dddd dd-mmm- yy") .Show End With End Sub . . |
All times are GMT +1. The time now is 04:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com