I have vba code that works on another workbook, but for whatever reason it will not work on a new workbook when I inserted into new workbook. When the button is pressed to create the PDF's, the code will take a record number from a cell on the excel worksheet (I1) (ie. 12) where the form is located and then pull data from a different worksheet, creating 12 pdf forms filled out with individualized info.
here is the original code that works:
here is the code adjusted for the new workbook:
When the macro is run I get a Run-time error '13': Type mismatch msgbox and the debugger points to the red text in the code
The record number in Range(F3) is an alpha-numeric number (ie... A026) as required. Once I enter the Record number into F3 and click the save button, the number entered changes to 1 and then continues to save countless pdf doc's in the designated folder and the info isn't populated, I have to press the ESC key for it to stop saving pdf doc's. I think that is where the Type mismatch error comes from, but as a newbie I don't know how to fix it.
Thank you for any assistance.
dlmoore99
here is the original code that works:
Code:
Sub PDFCreate()
RowCount = Worksheets("Items").Cells(Rows.Count, 1).End(xlUp).Row - 1
Worksheets("DD1348").Select
For i = 1 To RowCount
Range("I1").Value = i
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\dana.l.moore\Desktop\DD Form 1348\" & Range("BG3").Value, Quality:=xlQualityStandard, IncludeDocProperties:= _
True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
End Sub
here is the code adjusted for the new workbook:
Code:
Sub Batch_DA37499()
RowCount = Worksheets("DataEntry").Cells(Rows.Count, 1).End(xlUp).Row - 1
Worksheets("Ind-Batch Weapon Card").Select
For i = 1 To RowCount
Range("F3").Value = i
[COLOR=#FF0000] ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\dana.l.moore\Desktop\DA Form 3749\DA 3749 " & Range("G9").Value & " " & Range("B17").Value, Quality:=xlQualityStandard, IncludeDocProperties:= _
True, IgnorePrintAreas:=False, OpenAfterPublish:=False[/COLOR]
Next I
End Sub
When the macro is run I get a Run-time error '13': Type mismatch msgbox and the debugger points to the red text in the code
The record number in Range(F3) is an alpha-numeric number (ie... A026) as required. Once I enter the Record number into F3 and click the save button, the number entered changes to 1 and then continues to save countless pdf doc's in the designated folder and the info isn't populated, I have to press the ESC key for it to stop saving pdf doc's. I think that is where the Type mismatch error comes from, but as a newbie I don't know how to fix it.
Thank you for any assistance.
dlmoore99