08-28-2015
10:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-28-2015
10:20 AM
Thry this one
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oDXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Define the drawing
Dim oDrawing As DrawingDocument
oDrawing = ThisDoc.Document
Dim oSheet As Sheet
Dim lPos As Long
Dim rPos As Long
Dim sLen As Long
Dim sSheetName As String
Dim sSheetNumber As Integer
'step through each drawing sheet
Dim Response As MsgboxResult
For Each oSheet In oDrawing.Sheets
Response = MsgBox("Yes = Save or No = Continue to next Sheet?", MsgBoxStyle.YesNo, "Question")
If Response = MsgBoxResult.Yes Then
'find the seperator in the sheet name:number
lPos = InStr(oSheet.Name, ":")
'find the number of characters in the sheet name
sLen = Len(oSheet.Name)
'find the sheet name
sSheetName = Left(oSheet.Name, lPos - 1)
'find the sheet numbe
sSheetNumber = Right(oSheet.Name, sLen - lPos)
End If
ActiveSheet = ThisDrawing.Sheet(oSheet.Name)
If Response = MsgBoxResult.Yes Then
'find the seperator in the sheet name:number
lPos = InStr(oSheet.Name, ":")
'find the number of characters in the sheet name
sLen = Len(oSheet.Name)
'find the sheet name
sSheetName = Left(oSheet.Name, lPos - 1)
'find the sheet numbe
sSheetNumber = Right(oSheet.Name, sLen - lPos)
'get DXF target folder path
oFolder = "c:\INVENTOR DXF FILES"
'Set the DXF target file name
oDataMedium.FileName = oFolder & "\" & sSheetName & sSheetNumber & ".dxf"
MessageBox.Show("DXF SAVED TO: " & oDataMedium.FileName, "DXF Saved", MessageBoxButtons.OK)
'Publish document
oDXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End If
Next