Changing Userform popup based on document name

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Trying to have 3 different userforms popup based on the document having three different names- basically I want a userform to popup when the document is the "template" then once it gets saved as "working" for the first time, a different userform will popup, then as it gets saved as again "archive ###" it will have a third user form popup when opening. Guessing this would be a series of If's.

thanks
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
The IFS would surely work too

Something like a Select Case statement could be used

Code:
Sub UserformPopUp()
    Select Case NameofFile'Assuming you have extracted the anem of the file (as in Template, working e.t.c)
        Case "Template"
            Userform1.Show
        Case "Working"
            Userform2.Show
        Case "Archive"
            Userform3.Show
    End Select
End Sub
 
Upvote 0
What I had is below. It is giving me a "424 Object Required" Error. What do I need to do? Or, how could I modify your code to make userform3 equal to the archive section, because the "Archive" is a changing name- each time this workbook is finished and archived, it has a "#""L or B" and then "Name" - "Name"

thanks!

Code:
Private Sub Workbook_Open()
If ActiveWorkbook.Name = "Master Voyage Report.xlsm" Then
    Userform1.Show
    Applications.Visible = False
ElseIf Activework.Name = "Current Voyage Report.xlsm" Then
    Userform2.Show
    Applications.Visible = False
Else: Userform3.Show
    Applications.Visible = False
End If
End Sub
 
Upvote 0
Where are you getting the error? on what line, maybe the
Code:
Activework.Name
which should be4
Code:
Activeworkbook.Name
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,577
Members
449,039
Latest member
Arbind kumar

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