Printing to a folder with new DWF printer

Printing to a folder with new DWF printer

Anonymous
Not applicable
400 Views
3 Replies
Message 1 of 4

Printing to a folder with new DWF printer

Anonymous
Not applicable
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
0 Likes
401 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Might try setting SilentOperation and see if it helps.

--
Kent
Assistant Moderator
Autodesk Discussion Forum Moderator Program


"Joe Bartels" wrote in message
news:9D789BBCFD28C8EDFC444F255C3DFB88@in.WebX.maYIadrTaRb...
> 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.
0 Likes
Message 3 of 4

Anonymous
Not applicable
I modified the code to add

ThisApplication.SilentOperation = True

I'm still getting two dialog boxes.

Thanks for the suggestion though.

"Kent Keller" wrote in message
news:6C3C7AD14F4BDE40268CDBEAB322D6AB@in.WebX.maYIadrTaRb...
> Might try setting SilentOperation and see if it helps.
>
> --
> Kent
> Assistant Moderator
> Autodesk Discussion Forum Moderator Program
>
>
> "Joe Bartels" wrote in message
> news:9D789BBCFD28C8EDFC444F255C3DFB88@in.WebX.maYIadrTaRb...
> > 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.
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
Ok, with the following code I can get it to bring up the dialog box only
once with the correct filename in the dialog box, but how do I get this to
run silently, and saved to a specific server directory? Am I doing the
SilentOperation wrong?

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)

ThisApplication.SilentOperation = True

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
szFileName = "I:\Autodesk Inventor\DWF\" & szFileName
Call
ThisApplication.CommandManager.PostPrivateEvent(kFileNameEvent, szFileName)
oPrintMgr.SubmitPrint

End If
End If
ThisApplication.SilentOperation = False
End Sub
0 Likes