Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
J_Pfeifer_
in reply to: luntzj

I wrote something up that's much more direct in how to do something like you asked. Note, this has not been tested but it shows the exact logic I'd use in two different ways to solve this problem. I noticed some missing or weird overlaps between the drawing sheet size and paper size. These might need to be accounted for in multiple ways. That is you may not be able to use a single method in this pasted code. It may require more than one. 

 

Lastly, I would move the selections into a sub routine. This way you can call the sub when you need to make a new selection on or from a different sheet. 

 

 

Sub main()
	
	Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim Printmanager As PrintManager = oDoc.PrintManager
	
	Printmanager.ScaleMode = kPrintBestFitScale
	Printmanager.PrintRange = kPrintAllSheets
	Printmanager.Orientation = kLandscapeOrientation
	
	Dim Sheetsize As DrawingSheetSizeEnum = Nothing
	
	For Each osheet As Sheet In oDoc.Sheets
		If osheet IsNot Nothing Then 
			Sheetsize = osheet.Size()
			Logger.Info("Sheet object size: " & osheet.Size.ToString & " Sheet size: " & Sheetsize.ToString)
		End If 
	Next
	
	Dim PaperSizeSel As PaperSizeEnum = Nothing
	
	Dim osheet1 As Sheet = Nothing
	Try 'Placed into try block as this isnt the best way to get access to the sheet. Try to make it dynamic so this doesnt error. 
		osheet1 = oDoc.Sheets.Item(1)
	Catch
	End Try
	
		'Inside the webpages describing each item, you see a numeric value, for example Ddrawing size is value = 9990. You may want to experiment what you need to pass for ojects here
		'Strings, enumerators as shown, or maybe change the varable type and simplye use the values. Many options. 
		Select Case Sheetsize
		
		Case DrawingSheetSizeEnum.kDDrawingSheetSize
			
			PaperSizeSel = PaperSizeEnum.kPaperSizeDSheet
	
		Case DrawingSheetSizeEnum.kA1DrawingSheetSize
			
			PaperSizeSel = PaperSizeEnum.kPaperSizeA1
		
		Case Else 
		
			MessageBox.Show("Incorrect size selected doing manual check")
			
		End Select
				
	'Apply the changes to the print manager
	
	Printmanager.PaperSize = PaperSizeSel
		
				
				
				
	Dim sheetwidth As Double = Nothing
	Dim sheetheight As Double = Nothing

	sheetwidth = osheet1.Width
	sheetheight = osheet1.Height
	
	
	If sheetwidth = 17 * 2.54 And sheetheight = 11 * 2.54 Then 
		PaperSizeSel = PaperSizeEnum.kPaperSize11x17
	Else	
		'continue depending. 
	End If
	
	
	'or again apply the changes as needed
	
	Printmanager.PaperSize = PaperSizeSel
	

	
End Sub

 

 

If you feel I fulfilled your question, a solution would be greatly appreciated!