Save as Copy to pdf user specified end sheet

Save as Copy to pdf user specified end sheet

timothy_berg
Advocate Advocate
149 Views
2 Replies
Message 1 of 3

Save as Copy to pdf user specified end sheet

timothy_berg
Advocate
Advocate

Hello, I need some help with the code below.

My goal is to have the user enter a number into the message box and that will set the range of sheets to be printed to a pdf.
When I remove the myparam from this line of code oOptions1.Value("Custom_End_Sheet") = myparam and enter a number (for example oOptions1.Value("Custom_End_Sheet") = 5) the code works, I can't figure out how to get the number from the input box to the end sheet.

 

myparam = InputBox("", "END SHEET", "3")
Custom_End_Sheet = myparam
iProperties.Value("Custom", "ISSUED_BY")=ThisApplication.GeneralOptions.UserName
iProperties.Value("Custom", "ISSUE_DATE")=Now
InventorVb.DocumentUpdate()
' Get the PDF translator Add-In.
Dim PDFAddIn As TranslatorAddIn
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
'Set a reference to the active document (the document to be published).
Dim oDocument1 As Document
oDocument1 = ThisApplication.ActiveDocument
Dim oContext1 As TranslationContext
oContext1 = ThisApplication.TransientObjects.CreateTranslationContext
oContext1.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions1 As NameValueMap
oOptions1 = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium1 As DataMedium
oDataMedium1 = ThisApplication.TransientObjects.CreateDataMedium
 'Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(oDocument1, oContext1, oOptions1) Then
' Options for drawings...
oOptions1.Value("All_Color_AS_Black") = 1
'oOptions1.Value("Remove_Line_Weights") = 0
oOptions1.Value("Vector_Resolution") = 4800
oOptions1.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
oOptions1.Value("Custom_Begin_Sheet") = 1
'MessageBox.Show(Custom_End_Sheet, "END SHEET")
oOptions1.Value("Custom_End_Sheet") = myparam' this line is the line in question
End If
oPath1 = ThisDoc.Path
oDataMedium1.FileName = oPath1 & "\Transmittal\" & ThisDoc.FileName(False) & " (" & DateString & ")" & ".pdf"
Call PDFAddIn.SaveCopyAs(oDocument1, oContext1, oOptions1, oDataMedium1)



 

0 Likes
Accepted solutions (1)
150 Views
2 Replies
Replies (2)
Message 2 of 3

jjstr8
Collaborator
Collaborator
Accepted solution

You just need to convert myparam to an Integer. The TryParse will account for non-integer entries. I would put everything in the .HasSaveCopyAsOptions If statement as well.

 

 'Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(oDocument1, oContext1, oOptions1) Then
	' Options for drawings...
	oOptions1.Value("All_Color_AS_Black") = 1
	'oOptions1.Value("Remove_Line_Weights") = 0
	oOptions1.Value("Vector_Resolution") = 4800
	oOptions1.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintSheetRange
	oOptions1.Value("Custom_Begin_Sheet") = 1
	'MessageBox.Show(Custom_End_Sheet, "END SHEET")
	Dim endSheet As Integer
	If Integer.TryParse(myparam.ToString, endSheet)
		oOptions1.Value("Custom_End_Sheet") = endSheet' this line is the line in question
		oPath1 = ThisDoc.Path
		oDataMedium1.FileName = oPath1 & ThisDoc.FileName(False) & " (" & DateString & ")" & ".pdf"
		Call PDFAddIn.SaveCopyAs(oDocument1, oContext1, oOptions1, oDataMedium1)
	End If
End If

 

0 Likes
Message 3 of 3

timothy_berg
Advocate
Advocate

That makes sense now, thanks for the help!!

0 Likes