114
1万
中流砥柱
使用道具 举报
10
973
909
初露锋芒
34
105
91
后起之秀
Public MyTxtStr(0 To 3) As StringPublic Cnt As IntegerPublic WorkbookOpen As IntegerPublic RowCnt As IntegerPublic ErrorHandler As ErrorPublic Excel As Excel.ApplicationPublic ExcelSheet As ObjectPublic ExcelWorkbook As ObjectPublic CurrRange As RangeSub DrgRecivedRegAutoComplete3()'allows selecting text on screen'stores the text valueDim MyMTxt As AcadMTextDim MyoEnt As AcadEntityDim MyObjSS As AcadSelectionSetDim i As Doublei = 0'On Error Resume NextThisDrawing.SelectionSets("Selecttext").DeleteOn Error Resume Next Set MyObjSS = ThisDrawing.SelectionSets.Add("Selecttext") '' create a new selectionset MyObjSS.SelectOnScreen '' let user select entities interactively ' ThisDrawing.Utility.prompt objSS.Count & " entities selected" ' ThisDrawing.Utility.GetString True, vbLf & "Enter to continue Escape To Exit" MyObjSS.Highlight True If MyObjSS.Count = "0" Then GoTo ErrorHandler For Each MyoEnt In MyObjSS If TypeOf MyoEnt Is AcadMText Then Set MyMTxt = MyoEnt MyTxtStr(i) = MyMTxt.TextString MyObjSS.Highlight False i = i + 1 End If Next Cnt = MyObjSS.Count - 1 Tranfer2ExcelErrorHandler:CloseEnd SubPrivate Sub Tranfer2Excel() If WorkbookOpen = 1 Then GoTo SkipCreatingWorkbook ' Launch Excel. Set Excel = New Excel.Application ' Create a new workbook and find the active sheet. Set ExcelWorkbook = Excel.Workbooks.Add Set ExcelSheet = Excel.ActiveSheet ExcelWorkbook.SaveAs "Drawing Register Transfer Sheet.xls" Excel.Visible = True RowCnt = 1 With Worksheets("Sheet1") .Select .Range("a1").Activate End With SkipCreatingWorkbook: For i = 0 To Cnt Set CurrRange = ActiveCell CurrRange.Value = MyTxtStr(i) CurrRange.Offset(0, 1).Select Next RowCnt = RowCnt + 1 With Worksheets("Sheet1") .Select