Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This code worked years back, and i just start to use again and have problem. I got error Argument 'Length' must be greater or equal to zero. Could you guys help to solve this problem. Thank you
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 number sSheetNumber = Right(oSheet.Name, sLen - lPos) ActiveSheet = ThisDrawing.Sheet(oSheet.Name) 'get DXF target folder path oFolder = "C:\TEMP" '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
I hgit error Argument 'Length' must be greater or equal to zero
Solved! Go to Solution.