I want to create a VBA code that pastes different columns within a row to a pdf, then move to the next row and do this to 30 different rows. Then I want it to save the document then continue from where it left off. Therefore, after 30 rows have had their columns pasted into the text boxes within a pdf, it would save the document, re-open the original document then paste the next set of 30 rows.
I have the following code doing all of this until the first set of 30, but I'm not sure how to make it loop and continue it's count. Any suggestions?
I have the following code doing all of this until the first set of 30, but I'm not sure how to make it loop and continue it's count. Any suggestions?
VBA Code:
Sub PDFTemplate()
Dim PDFFldr As FileDialog
Set PDFFldr = Application.FileDialog(msoFileDialogFilePicker)
With PDFFldr
.Title = "Select PDF File to Attach"
.Filters.Add "PDF Type Files", "*.pdf", 1
If .Show <> -1 Then GoTo NoSelection
Sheet1.Range("K3").Value = .SelectedItems(1)
End With
NoSelection:
End Sub
Sub SavePDFFolder()
Dim PDFFldr As FileDialog
Set PDFFldr = Application.FileDialog(msoFileDialogFolderPicker)
With PDFFldr
.Title = "Select a Folder"
If .Show <> -1 Then GoTo NoSel:
Sheet1.Range("K6").Value = .SelectedItems(1)
End With
NoSel:
End Sub
Sub CreatePDFForms()
Dim PDFTemplateFile, NewPDFName, SavePDFFolder, PipeSupportName, Unit As String
Dim SupportRow, LastRow As Long
With Sheet1
LastRow = .Range("F2").End(xlUp).Row 'Last Row
PDFTemplateFile = .Range("K3").Value 'Template File Name
SavePDFFolder = .Range("K6").Value 'Where File will be saved
ActiveWorkbook.FollowHyperlink Address:=.Range("K3")
Application.Wait Now + 0.00006
For SupportRow = 2 To 31 'TEST ROWp
ProjectName = .Range("A" & SupportRow).Value 'Project Name
PipeSupportName = .Range("F" & SupportRow).Value 'Pipe Support Name
Unit = .Range("H" & SupportRow).Value 'Unit Number
Application.SendKeys "{Tab}", True
Application.SendKeys ProjectName, True
Application.Wait Now + 0.00002
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("B" & SupportRow).Value, True 'Project#
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("C" & SupportRow).Value, True 'System#
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("D" & SupportRow).Value, True 'Drawing #
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("H" & SupportRow).Value, True 'Unit #
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("E" & SupportRow).Value, True 'Description
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("F" & SupportRow).Value, True 'SupportName
Application.Wait Now + 0.00001
Application.SendKeys "{Tab}", True
Application.SendKeys .Range("G" & SupportRow).Value, True 'PipeSpool/Line#
Application.Wait Now + 0.00001
Application.SendKeys "{Enter}", True 'Enter
Application.Wait Now + 0.00005
Application.SendKeys "^(S)", True 'Control Save As
Application.Wait Now + 0.00004
Application.SendKeys .Range("F" & SupportRow).Value, True 'SupportName
Application.Wait Now + 0.00001
'Application.SendKeys "^(p)", True 'Control P
'Application.Wait Now + 0.00006
Application.SendKeys "{Enter}", True 'Enter
Application.Wait Now + 0.00005
'
'
Next SupportRow
End With
End Sub