Hello,
I have a procedure running off of a userform. Within that procedure, I am using Application.Run to call a sub in another workbook. When I step through my code, the Application.Run line to call the other sub works perfectly, the sub runs perfectly, but when my highlighted line is “End Sub” where it should transfer control back to my main procedure, it gives me Error 424: Object Required. Then, when I hit debug, the line that is highlighted as the problem is my original Application.Run line, which worked fine in the first place.
Here’s my code:
Select Case PartType
Case "Nozzle Ring"
Select Case FrameSize
Case "HE300"
If Dir("G:\TES\Private\Quality Control\Jobs\Cummins CTT\300 Series Nozzle Rings\" & Input_PartNum, vbDirectory) = "" Then
MkDir ("G:\TES\Private\Quality Control\Jobs\Cummins CTT\300 Series Nozzle Rings\" & Input_PartNum)
End If
If Dir("G:\TES\Private\Quality Control\Jobs\Cummins CTT\300 Series Nozzle Rings\" & Input_PartNum & "\" & Input_JobNum) = "" Then
MkDir ("G:\TES\Private\Quality Control\Jobs\Cummins CTT\300 Series Nozzle Rings\" & Input_PartNum & "\" & Input_JobNum)
End If
‘The line below is where I call my sub in the other workbook
Application.Run("'Meas.Form-03_HE300 Verification Template_rev00.xlsm'!FillsCells", [Input_PartNum], [Input_JobNum], [Input_PotNum], [LabTechName]) = True
AWorkbk.SaveAs ("G:\TES\Private\Quality Control\Jobs\Cummins CTT\300 Series Nozzle Rings\" & Input_PartNum & "\" & Input_JobNum & "\" & Input_JobNum & ".xlsm")
Here's the sub under the other workbook:
Sub FillsCells(PartNum As Variant, JobNum As String, PotNum As String, LabTech As String)
Sheet3.Range("B4") = JobNum
Sheet3.Range("B5") = PartNum
Sheet3.Range("G4") = Date
Sheet3.Range("H5") = PotNum
Sheet2.Range("D19") = LabTech
I’m finding this all pretty confusing…which line is the error actually on? Does it have something to do with transferring control back to the procedure written in the userform? I’ve run the program omitting calling the sub under the other workbook entirely, and everything works great.
Also: I know that in this line
Application.Run("'Meas.Form-03_HE300 Verification Template_rev00.xlsm'!FillsCells", [Input_PartNum], [Input_JobNum], [Input_PotNum], [LabTechName]) = True
the “=True” isn’t correct syntax. But VBA kept prompting me that my syntax was incorrect when I didn’t have it. It would say “Compile Error: Expected:=” and then when I just put an equals sign, it would say “Compile Error: Expected: Expression” So I just put “=True” in there to make it happy. Could that be the problem?
Bookmarks