Import leader text to excel: Upgrade of current code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
A user here on the board, was kind enough to provide me with the following code. The code extracts the value from leader texts to excel.
But i have some wishes for improvement of this code, for our daily use.
1. The code should only extract leader text with $ in front of it
2. I'd like to have a predefined text in the spreadsheet, for A1 and B1 (ie A1 = Current Value / B1 = New Value)
3. All cells are set to "Standard"
4. This would probably have to be separate code, but a code that can import the new value from the spreadsheet back into inventor and replace the current value leader text with the new value.
Example:
- I export to excel
- Value in A2 is $123
- I enter 555 in B2 as the new value
- Click save in excel
- Run import rule in Inventor
- And the leader text that had previously said $123, now gets replaced by 555 (info: we expect to have multiple leader texts on our drawing)
Dim oDoc As DrawingDocument = ThisDoc.Document Dim OFullName As String = oDoc.FullFileName 'Remove file extension Dim oExcelName As String = Left(OFullName, (InStrRev(OFullName, ".", - 1, vbTextCompare) - 1)) & ".xlsx" Dim row As Integer = 2 ''' Indicate from which row the read of excel values will begin xlApp = CreateObject("Excel.Application") xlApp.Visible = True xlWorkbook = xlApp.Workbooks.Add xlWorksheet = xlWorkbook.Worksheets.Item(1) For Each oLeaderNote As LeaderNote In oDoc.ActiveSheet.DrawingNotes.LeaderNotes oValue = oLeaderNote.Text xlWorksheet.Range("A" & row).Value = oValue row = row + 1 Next 'set all of the columns to autofit xlWorksheet.Columns.AutoFit 'save the file xlWorkbook.SaveAs(oExcelName) 'xlWorkbook.Close 'xlApp.Quit 'xlApp = Nothing