Save DWF of Active Document in Specified File Location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Pretty simple, I'm writing a macro to save a DWF of an active document in a specific folder for our ECR/ECN process. Every macro seems really long and has additional functionality built into it. I AM HOPING that is why they are as long as they are because this should be a lot easier than it seems like it is. Currently I am going to down 2 paths but returning a file path as a string is clearly triggering Inventor. Trying to use the strFileName it tells me an object is needed, if I comment it out and use the ExportDocName it tells me object variable or with block variable not set. What is the proper variable for returning a file path? Asking because it seems to work fine as a string in the second one.
Secondly I feel like I went down this path and found out it only exports the active page, will that be the case with this code? What's the preferred method for getting all the pages and none of the 3d files? Print manager vs DWF add in? Is it possible to do without the DWF add in? This kind of seems really difficult for exporting something that should be considered a native format...
Public Sub AutoSave()
' Get the filename minus the extension.
Dim strFilename As String
Dim dwfDirectory As String
Dim ExportDocName As String
Dim ExportDoc As DrawingDocument
dwfDirectory = "C:\Users\ MY DESKTOP "
strFilename = ActiveDoc.fullFilename
ExportDocName = ExportDoc.fullFilename
strFilename = Left(strFilename, Len(strFilename) - 4)
' Save the current SilentOperation and then turn it on.
' This will suppress the dwf viewer from being displayed.
Dim currentSetting As Boolean
currentSetting = ThisApplication.SilentOperation
ThisApplication.SilentOperation = True
' Save the file as dwf.
'Call ThisDocument.SaveAs(dwfDirectory & strFilename & ".dwf", True)
' Reset SilentOperation back to its previous value.
ThisApplication.SilentOperation = currentSetting
Debug.Print "Full save name is " & dwfDirectory & strFilename & ".dwf"
End Sub
Working macro
Public Sub ExportDWF()
Dim ExportDoc As DrawingDocument
Dim ExportDocName As String
Set ExportDoc = ThisApplication.ActiveDocument
ExportDocName = ExportDoc.fullFilename
Debug.Print "File name is " & ExportDocName
End Sub