Conditional Userforms at Workbook Open

Farah

Board Regular
Joined
Oct 4, 2005
Messages
98
Hello,

I have tried to do something, which i have achieved most of it, but getting some problem in it.

I want to do something like this as in code:

Code:
Private Sub Workbook_Open()

Sheets("abc").Activate
Application.Wait 2
UserForm6.Show
If pExit = True Then Exit Sub
Application.Quit
Application.Wait 2
If ActiveWorkbook.Name = "Farah.xls" Then
  
    UserForm3.Show
    If pExit = True Then Exit Sub
    Me.Saved = True
    Application.Quit
Else
    UserForm4.Show
End If

End Sub


Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True

If ActiveWorkbook.Name <> "Farah.xls" Then Exit Sub
UserForm4.Show
End Sub


What the above code should do :

At the workbook open, show userform6; i will press one button on userform3, which will unload it. Code is as follows:

Userfrm6 code:.

Code:
Private Sub CommandButton1_Click()
Unload Me
UserForm3.Show
End Sub

Once userform6 is unload, it will check If File name is Farah, then userform3.show

Userform3 has one textboxes on which a "new workbook name" is to be given and there is a commandbutton. Once a name is given in textbox and commandbutton is pressed, it will only allow for this workbook to be saved with another name like a Saveas function and the opened file will close and saved file will remain on the screen.

Once the saved workbook is also closed. and it is re-opened again, it shows Userform6 again and if File name is not Farah, it should show Userform4 but in my case, it is again showing userform3 as in the code.

Why is it showing Userform3 in the newly saved workbook.. I want it to show Userform4 instead of Userform3.

What am i doing wrong in the code ?


Thank you for your help.

Warm Regards,
Farah
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Farah

What are you actually trying to achieve?

Could you explain without referring to the various forms?
 
Upvote 0
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True

If ActiveWorkbook.Name <> "Farah.xls" Then Exit Sub

UnLoad Me

UserForm4.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,755
Members
449,049
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top