LordDragon
06-30-2015, 02:40 PM
Greetings,
I will be posting this on VBA Express, Mr. Excel, & Excel Forum. I apologize if this counts as a "duplicate post".
I have an Inventory/Order Form workbook that I'm building that allows the user to create an order from the inventory of available parts, consolidate the duplicates and export the order as either an Excel file or a PDF; but doesn't export the rest of the inventory.
All that stuff works great. But now I have been tasked with including the customer information. So I added a page that will contain that info, but it needs to be exported also. What I would like is to simply save the Customer Info page and the Order Info page into an Excel Workbook. I also would like to save them both into a single PDF file, with the Customer Info on the first page.
Here is the code I am currently using for both.
Excel
Sub CreateXLS()
'Saves the Order Info page as a separate Excel workbook.
Dim strFile As String
strFile = ThisWorkbook.Path & "\"
If Dir(strFile, vbDirectory) = "" Then
MkDir (strFile)
End If
'Save the Order Info page as an Excel Workbook
ActiveSheet.Copy
With ActiveWorkbook
.SaveAs strFile & .Sheets(1).Name
.Close 0
End With
End Sub
PDF
Sub CreatePDF()
'Saves the Order Info page as a PDF file.
Dim strFile As String
strFile = ThisWorkbook.Path & "\"
If Dir(strFile, vbDirectory) = "" Then
MkDir (strFile)
End If
'Save the Order Info page as a PDF
Application.Goto Sheets("Order Info").Range("A1"), True
With Sheets("Order Info")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFile & "Order Info.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
End Sub
How can I change either one to do what I need?
Thanks.
I will be posting this on VBA Express, Mr. Excel, & Excel Forum. I apologize if this counts as a "duplicate post".
I have an Inventory/Order Form workbook that I'm building that allows the user to create an order from the inventory of available parts, consolidate the duplicates and export the order as either an Excel file or a PDF; but doesn't export the rest of the inventory.
All that stuff works great. But now I have been tasked with including the customer information. So I added a page that will contain that info, but it needs to be exported also. What I would like is to simply save the Customer Info page and the Order Info page into an Excel Workbook. I also would like to save them both into a single PDF file, with the Customer Info on the first page.
Here is the code I am currently using for both.
Excel
Sub CreateXLS()
'Saves the Order Info page as a separate Excel workbook.
Dim strFile As String
strFile = ThisWorkbook.Path & "\"
If Dir(strFile, vbDirectory) = "" Then
MkDir (strFile)
End If
'Save the Order Info page as an Excel Workbook
ActiveSheet.Copy
With ActiveWorkbook
.SaveAs strFile & .Sheets(1).Name
.Close 0
End With
End Sub
Sub CreatePDF()
'Saves the Order Info page as a PDF file.
Dim strFile As String
strFile = ThisWorkbook.Path & "\"
If Dir(strFile, vbDirectory) = "" Then
MkDir (strFile)
End If
'Save the Order Info page as a PDF
Application.Goto Sheets("Order Info").Range("A1"), True
With Sheets("Order Info")
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFile & "Order Info.pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
End Sub
How can I change either one to do what I need?
Thanks.