Message 1 of 4
Printing to a folder with new DWF printer

Not applicable
09-10-2003
01:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I had set up a macro in my templates that would save a DWF to a specific
folder on our server every time an IDW is saved, without any user
intervention. This worked ok, but we would have problems if there was
anything off of the sheet size. I have tested the new DWFwriter and it
solves the centering problem with the Best Fit option, but I am having
trouble implementing it with a macro.
I have got to the point with the following code where it will send it to
print, but it always prompts me twice for a file location. I'ld like to get
it to the point where it would just print to a file the DWF to the server
folder location with the same file name as the IDW. I'm not a VBA expert by
any means, so any help would be appreciated. Thanks in advance.
Joe Bartels
Option Explicit
Private obDocument As Document
Public WithEvents DocEvents As DocumentEvents
Public Sub AutoSave_Copy_by_Event()
Set DocEvents = ThisApplication.ActiveDocument.DocumentEvents
End Sub
Public Sub DocEvents_OnSave(ByVal BeforeOrAfter As EventTimingEnum, ByVal
Context As NameValueMap, HandlingCode As HandlingCodeEnum)
SaveAsType "dwf"
End Sub
Private Sub SaveAsType(szFileType As String)
Set obDocument = ThisApplication.ActiveDocument
If obDocument.DocumentType <> 12292 Then
Exit Sub
Else
Dim szFileName As String
Dim szExtension As String
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
'This is the name of the DWF printer on my system. Probably should
'Determine this by other means.
oPrintMgr.Printer = "Autodesk DWFwriter"
oPrintMgr.NumberOfCopies = 1
oPrintMgr.Orientation = kLandscapeOrientation
oPrintMgr.ScaleMode = kPrintBestFitScale
oPrintMgr.PrintRange = kPrintAllSheets
'get the full file name from obDocument
szFileName = obDocument.DisplayName
'Determine the extension of the file
szExtension = Right(szFileName, 3)
'If the extension is IDW then print a DWF of the file, if not do nothing
If szExtension = "idw" Then
szFileName = Left(szFileName, Len(szFileName) - 3) & szFileType
'Set our server folder location
szFileName = "I:\Autodesk Inventor\DWF\" & szFileName
oPrintMgr.PrintToFile (szFileName)
End If
End If
End Sub
folder on our server every time an IDW is saved, without any user
intervention. This worked ok, but we would have problems if there was
anything off of the sheet size. I have tested the new DWFwriter and it
solves the centering problem with the Best Fit option, but I am having
trouble implementing it with a macro.
I have got to the point with the following code where it will send it to
print, but it always prompts me twice for a file location. I'ld like to get
it to the point where it would just print to a file the DWF to the server
folder location with the same file name as the IDW. I'm not a VBA expert by
any means, so any help would be appreciated. Thanks in advance.
Joe Bartels
Option Explicit
Private obDocument As Document
Public WithEvents DocEvents As DocumentEvents
Public Sub AutoSave_Copy_by_Event()
Set DocEvents = ThisApplication.ActiveDocument.DocumentEvents
End Sub
Public Sub DocEvents_OnSave(ByVal BeforeOrAfter As EventTimingEnum, ByVal
Context As NameValueMap, HandlingCode As HandlingCodeEnum)
SaveAsType "dwf"
End Sub
Private Sub SaveAsType(szFileType As String)
Set obDocument = ThisApplication.ActiveDocument
If obDocument.DocumentType <> 12292 Then
Exit Sub
Else
Dim szFileName As String
Dim szExtension As String
Dim oPrintMgr As DrawingPrintManager
Set oPrintMgr = ThisApplication.ActiveDocument.PrintManager
'This is the name of the DWF printer on my system. Probably should
'Determine this by other means.
oPrintMgr.Printer = "Autodesk DWFwriter"
oPrintMgr.NumberOfCopies = 1
oPrintMgr.Orientation = kLandscapeOrientation
oPrintMgr.ScaleMode = kPrintBestFitScale
oPrintMgr.PrintRange = kPrintAllSheets
'get the full file name from obDocument
szFileName = obDocument.DisplayName
'Determine the extension of the file
szExtension = Right(szFileName, 3)
'If the extension is IDW then print a DWF of the file, if not do nothing
If szExtension = "idw" Then
szFileName = Left(szFileName, Len(szFileName) - 3) & szFileType
'Set our server folder location
szFileName = "I:\Autodesk Inventor\DWF\" & szFileName
oPrintMgr.PrintToFile (szFileName)
End If
End If
End Sub