I have a macro to save a part as a PDF in a specific folder our ERP system uses to show thumbnails. Because the PDFs created by SW have been too big, and have too much white space around the image, we have been resizing these PDFs in Adobe. It seems to me we should be able to eliminate this step. I experimented a bit and discovered that if I normalize the part window and drag one of the window corners to make the window smaller, then save as PDF, I get a smaller PDF. Can I set the current window to a specific size in a macro? How would that be done?
Here is what I came up with. The macro hides the FeatureManager and the Heads-up View Toolbar. Then it sets the window location and size, then switches the window to normal mode, and finally zooms the image to fit. If I trigger my Save as PDF or Save as JPG macros at this point, I get a 450 x 300 image. Now all I need to do is merge the macros and add a couple lines to unhide the FeatureManger and Heads-up View Toolbar, and Maximize the model window again. This is going to help me and my ERP people tremendously.
Option Explicit
Dim swApp As Object
Dim swDoc As ModelDoc2
Dim swDocExt As ModelDocExtension
Dim swDocView As ModelView
Dim PDFWidth As Integer
Dim PDFHeight As Integer
Sub main()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swDocExt = swDoc.Extension
Set swDocView = swDoc.ActiveView
' Hide FeatureManager
swDocExt.HideFeatureManager (True)
' Hide Heads-up View Toolbar
swDocView.VisibilityViewTools = False
' Set Document Window Postion
swDocView.FrameTop = 100
swDocView.FrameLeft = 100
' Set Document Window Size
PDFWidth = 450
PDFHeight = 300
swDocView.FrameWidth = PDFWidth + 15 'Window frame subtracts 15 pixels from graphic width
swDocView.FrameHeight = PDFHeight + 53 'Window frame subtracts 53 pixels from graphic hight
' Set Document Window to Normal
swDocView.FrameState = swWindowNormal
' Zoom Model to Fit
swDoc.ViewZoomtofit2
End Sub