- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all im back with another coding issue. The issue we have with our current macro for exporting pdfs is that I have to constantly go find the folder i want to save it at.
Current:
This is our current macro that goes with printing options. This always picks the last folder a file was saved too. Id like to fix this to pick the current idw's location/name so i can cut the time searching for the folder or at times forget i have to change it. Any suggestions? The one i found will write to the folders location/name great but i need the option to save it else where or name it something else when i get revision numbers. Any one able to help?
Private Sub UserForm_Initialize()
Set oDoc = ThisApplication.ActiveDocument
Set oPrint = oDoc.PrintManager
Set oProperties = oDoc.PropertySets.Item(4)
If oDoc.PropertySets.Item(2).Item("Category").Expression = "2" Then
Set oRevisionTable = oDoc.ActiveSheet.RevisionTables.Item(1)
Else
cmdShop.Enabled = False
cmdShopEng.Enabled = False
End If
If chbPDF.value = True Then
oPrint.Printer = "CutePDF Writer"
oPrint.ScaleMode = kPrintBestFitScale
oPrint.PaperSize = kPaperSize11x17
oPrint.NumberOfCopies = 1
oPrint.SubmitPrint
End If
I was thinking of trying to add something like
printsfileLocation=ThisDoc.Path
But i dont wanna mess with it too much yet without something concrete or better to go off of.
Edit:
Or if there is a way to add the option to rename the file or for it to add the tag "_RevNumber"
Sub Main printsfileLocation=ThisDoc.Path oMemberName=ThisDoc.FileName(False) 'without extension exportPDF(printsfileLocation, oMemberName, ThisApplication.activedocument) End Sub Sub exportPDF(oPath As String, oFileName As String, oDocument As Document) Try oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium Dim oDrawing as DrawingDocument = oDocument Dim sheetCount As Integer = oDrawing.Sheets.Count If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange oOptions.Value("Custom_Begin_Sheet") = 1 oOptions.Value("Custom_End_Sheet") = sheetcount End If oDataMedium.FileName = oPath & "\" & oFileName & ".pdf" ' check carefully this line oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Catch End Try End Sub
Solved! Go to Solution.