2016-07-13 16 views
1

Я не могу понять, что это ниже, это код .... Я ударил ошибку для второго случая, чтобы открыть форму frmBookingLCL.show имя формы правильно . Я не могу понять это. линию с **** нам линии ошибки. ПОМОГИТЕ !!Ошибка времени выполнения «424;» Требуемый объект для функции случая

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 
+1

Похоже, у нас нет формы с этим именем? –

+0

Привет, Тим, есть форма с этим именем. –

+0

Может возникнуть ошибка в процедуре 'Activate' или' Initilialize' объекта 'frmBookingLCL'? –

ответ

1

скорее всего, ошибка в вашей пользовательской форме. Смотрите комментарии кода.

я пытался повторить ниже вопрос:

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 

код в 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 

Так идя код инициализировать, либо вам не хватает или имеют неправильное имя для одного из этих элементов управления. frTrucker, CheckBox1, txtPickupDate. Как только вы их исправите, ошибка исчезнет.

+0

Я получил его, спасибо, ТАК МНОГО! –

+0

Приветствия!. и убедитесь, что вы отметили вопрос как ответ. – cyboashu

Смежные вопросы