runtime error 424 Object required or invalid qualifier

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
All I am wanting to do is add the formTitle in front of the original caption. I have tried formTitle.caption, formTitle.Text and formTitle.Value inside the "selectRangefrm.caption = formTitle & "Scheduled Quantity Selection Form"". and/or inside the Sub reNameUserfrmCaption. When I change the formTitle.property(caption,text,value), I get the invalid qualifier error. As far as I can notice everything is spelled correctly.

Code:
Private Sub UserForm_Initialize()    
    Call reNameUserfrmCaption
    selectRangefrm.Caption = formTitle & "Scheduled Quantity Selection Form"
End Sub

Code:
Sub reNameUserfrmCaption()    
    Dim formTitle As String


    Select Case ActiveWorkbook.Name


        Case Is = "SDPF - LINE 1 (SLAT).xlsx"
             formTitle = "Slat"
        Case Is = "SDPF - LINE 2A.xlsx"
            formTitle = "Uhlmann"
        Case Is = "SDPF - LINE 3.xlsx"
            formTitle = "Korber"
        Case Is = "SDPF - LINE 4.xlsx"
            formTitle = "IMA"
    End Select
    
End Sub

Thank You
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi,
untested but see if these updates to your codes will do what you want

Code:
Private Sub UserForm_Initialize()
    Me.Caption = reNameUserfrmCaption
End Sub

Code:
Function reNameUserfrmCaption() As String
    Dim formTitle As String
    Select Case ActiveWorkbook.Name
    
        Case Is = "SDPF - LINE 1 (SLAT).xlsx"
             formTitle = "Slat"
        Case Is = "SDPF - LINE 2A.xlsx"
            formTitle = "Uhlmann"
        Case Is = "SDPF - LINE 3.xlsx"
            formTitle = "Korber"
        Case Is = "SDPF - LINE 4.xlsx"
            formTitle = "IMA"
    End Select
    
    reNameUserfrmCaption = formTitle & " Scheduled Quantity Selection Form"
    
End Function

Dave
 
Upvote 0
Thank you for the quick response. First, YES!! it worked. I understand
Code:
[COLOR=#333333]reNameUserfrmCaption = formTitle & " Scheduled Quantity Selection Form"[/COLOR]
doing it this way makes more sense. Secondly I don't understand why the Sub had to be changed to a Function. When I put in your revision of the code, I forgot to change it to a function and received another error message and then realized what I did wrong and changed the Sub to a Function and then it worked. So my question is why? Thank you again.
 
Last edited:
Upvote 0
I don't understand why the Sub had to be changed to a Function. When I put in your revision of the code, I forgot to change it to a function and received another error message and then realized what I did wrong and changed the Sub to a Function and then it worked. So my question is why? Thank you again.

Could have been made to work keeping it s a Sub but thought Function easier.

I have tried formTitle.caption, formTitle.Text and formTitle.Value inside the "selectRangefrm.caption = formTitle & "Scheduled Quantity Selection Form"". and/or inside the Sub reNameUserfrmCaption. When I change the formTitle.property(caption,text,value), I get the invalid qualifier error.

based on what you said you were trying in your first post - You were attempting to use your Variable formTitle as an object variable but it is declared as a string hence the error message.


To assign an object expression to an object variable, use the Set keyword.

example:

Code:
'declare variable as range
 Dim ObjectVariableName as Range
 
'assign range to variable
Set ObjectVariableName = Worksheets("Sheet1").Range("A10")

After assignment is made, you can then use your ObjectVariableName as if it were the actual object.
This includes modifying its properties and using its methods.

You can change the value stored in cell A10 with the following statement:

Code:
ObjectVariableName.Value = 42

Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

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