I have VBA cmd button that exports data from access to excel sheets. This works great, but I need to then make PDF's. Can this be done all from the access side on the export. Or, do I have to set up a macro or vba on the excel side to convert to pdf?
This is a sample code I have already on the access vba side.
Dennis
This is a sample code I have already on the access vba side.
Code:
Private Sub CmdOpenJawsCover_Click()
On Error GoTo SubError
Dim xlApp As Excel.Application
Dim xlWkb As Excel.Workbook
Dim xlWks As Excel.Worksheet
Dim SQL2ndAsst As String
Dim rs2ndAsst As DAO.Recordset
SQL2ndAsst = " SELECT TblMembers.LastName, TblMembers.FirstName, TblMembers.Position, '2nd Asst Chief:' & "" "" & [FirstName] & "" "" & [LastName] AS SecondAsstChief " & _
" FROM TblMembers " & _
" WHERE TblMembers.Position='2nd Asst Chief' "
Set rsChief = CurrentDb.OpenRecordset(SQLChief, dbOpenSnapshot)
Set rs1stAsst = CurrentDb.OpenRecordset(SQL1stAsst, dbOpenSnapshot)
Set rs2ndAsst = CurrentDb.OpenRecordset(SQL2ndAsst, dbOpenSnapshot)
Set xlApp = New Excel.Application
Set xlWkb = xlApp.Workbooks.Open(CurrentProject.Path & "\Master\BookCover_Jaws.xlsx")
xlApp.Visible = True
With xlApp.ActiveWorkbook.Sheets("Jaws")
.Range("R7").Value = (rs2ndAsst!SecondAsstChief)
End With
SubExit:
On Error Resume Next
rsChief.Close
rs1stAsst.Close
Set rs2ndAsst = Nothing
Exit Sub
SubError:
MsgBox "Error Number: " & Err.Number & "=" & Err.Description, vbCritical + vbOKOnly, "An error occured"
GoTo SubExit
End Sub
Dennis