Results 1 to 2 of 2

Thread: [Resolved] CreateEventProc Type Mismatch for InputBox

Threaded View

  1. #1

    Thread Starter
    Addicted Member Beengie's Avatar
    Join Date
    Nov 2003
    Location
    Central Valley, CA
    Posts
    243

    Resolved [Resolved] CreateEventProc Type Mismatch for InputBox

    I am trying to insert code into a module in a new workbook. I am able to create the buttons and code without any issue. However I do have an issue with the Inputbox when it is being placed in the module. I get a Type Mismatch error. I have isolated the error to that line by debugging. I included the entire snippet just so it can be seen by those who would help me. I have tried to set the input type to "2" (string) as it still shows. I also have tried to change the string strAns to a variant (which I never do) in order to handle whatever it decided it wanted to be. I am stumped. I appreciate any help.

    Code:
    ' write button code
    With ActiveWorkbook.VBProject.VBComponents("Sheet" & intSheets + 2).CodeModule
         lngStartLine = .CreateEventProc("Click", strBttnName) + 1
         .InsertLines lngStartLine, _
         "Dim strAns as String: 'strAns = """"" & vbCrLf & _
         "Dim strBD As String: strBD = Worksheets(""WIP Main"").Range(""ContractSignedDate"").Value" & vbCrLf & _
         "Dim strED As String: strED = Worksheets(""WIP Main"").Range(""PlannedShipDate"").Value" & vbCrLf & vbCrLf & _
         "strAns = InputBox(""Enter date of completion"" & vbCrLf & ""("" & strBD & " - " & strED & "")"", ""Enter Date"", FormatDateTime(Now(), vbShortDate), Type:=2)" & vbCrLf & _
         "If strAns = """" Then" & vbCrLf & _
         "    Exit Sub" & vbCrLf & _
         "ElseIf fFillDate(CDate(strAns)) = False Then" & vbCrLf & _
         "    Exit Sub" & vbCrLf & _
         "End If" & vbCrLf & _
         "Application.EnableEvents = False" & vbCrLf & _
         "Range(""I" & Worksheets(strArrSheets(intSheets)).Range("A" & intX + 1).Value & "ED" & Left$(strArrSheets(intSheets), 3) & """" & ").Value = strAns" & vbCrLf & _
         "Range(""I" & Worksheets(strArrSheets(intSheets)).Range("A" & intX + 1).Value & "Per" & Left$(strArrSheets(intSheets), 3) & """" & ").Value = 1" & vbCrLf & _
         "Application.EnableEvents = True" & vbCrLf
    End With
    Thanks in advance. I have learned all I know from this forum. This place rocks!
    Last edited by Beengie; Jul 12th, 2013 at 03:32 PM. Reason: resolved
    BeengieHappy.Vaue = (SharksScore > OpponentsScore)

    Go Sharks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width