A. Weiss
A. Weiss

Reputation: 11

Run-time error '424;" Object Required for case function

i can not figure this out below is the code.... I hit the error for the 2nd case to open the form frmBookingLCL.show the form name is correct. I can't figure this out. the line with the **** us the error line. HELP!!

Public Sub SendBookingEmail()
    StartTime = Timer
    With Session
            'check first 2 letters of shipper's code, if not US raise error
            If IsStartPositionCorrect(5, 14, 2, "US") <> True Or IsStartPositionCorrect(5, 2, 8, "Customer") <> True And GetDisplayText(4, 20, 1) <> "0" Then
                If MsgBox("You don't appear to be in Logis ocean export US file. Please enter the file first and then run the macro.", vbOKOnly, "Export file verification....") Then
                    Exit Sub
                End If
            End If

            sTypeOfMessage = "booking"
            sShipmentType = Trim(.GetDisplayText(9, 61, 3))
            sFileType = Trim(.GetDisplayText(4, 32, 1))
            bFullVersion = False

            'On Error GoTo ErrHand

            'Get Outlook if it's running
            Set oOutlookApp = GetObject(, "Outlook.Application")

            'collect data fields for the e-mail body
            GetAllLogisDataBooking


            'Blow up the question form
            Select Case sShipmentType
                Case "FCL", "CMF", "CCS", "FPR"
                    frmBookingFCL.Show
                Case "LCL", "GWY", "CLD"
                    frmBookingLCL.Show**********ERROR HERE
                Case Else
                    frmBookingFCL.Show
                    'frmBookingOthers.Show
            End Select


    End With

    Finish = Timer
    TimeTook = Finish - StartTime
    MyMacroStats = GetProcedureStats("Booking Confirmation", TimeTook)


    Exit Sub

ErrHand:

        If Err = 429 Then
            MsgBox "Please note you must start Microsoft Outlook first."
            End
        End If

End Sub

Upvotes: 1

Views: 268

Answers (1)

cyboashu
cyboashu

Reputation: 10443

Most likely, the error is in your user form. See the code comments.

I tried to replicate the issue below:

Sub test()

'/Sub  to load the user form.

Dim x   As String

    x = "a"

    Select Case x
    Case "a", "b", "c"
        UserForm1.Show '/ It Will error-out here during debugging.
    End Select
End Sub

Code in UserForm1

Private Sub UserForm_Initialize()

    '/ Code from : https://msdn.microsoft.com/en-us/library/office/gg251554.aspx
    '/ Actually the error happens here.

    Dim RetVal ' Implicitly a Variant.
    ' Default property is assigned to Type 8 Variant RetVal.
    RetVal = CreateObject("Excel.Application")
    RetVal.Visible = True ' Error occurs here.
End Sub

So going by your intialize code, either you are missing or have incorrect name for one of these controls. frTrucker,CheckBox1,txtPickupDate. Once you correct them, the error will be gone.

Upvotes: 1

Related Questions