10 Replies Latest reply on Feb 15, 2016 9:14 PM by Divyanshu Bhardwaj

    Read text from TitleBlock in drawing

    Divyanshu Bhardwaj

      I'm trying to read some text from TitleBlock in a drawing sheet using VBA. The Problem i'm having is the 'Object not set'. I don't know why it's happening. Having hard time.

      Code:

      Dim swApp As SldWorks.SldWorks

      Sub main()

      Set swApp = Application.SldWorks

       

      Dim swDraw As SldWorks.DrawingDoc

      Set swDraw = swApp.ActiveDoc

      'swDraw.EditTemplate

       

      Dim swSheet As SldWorks.Sheet

      Set swSheet = swDraw.GetCurrentSheet()

       

      Dim sheet_name As String

      sheet_name = swSheet.GetName()

       

      Dim swTitle As SldWorks.TitleBlock

      Set swTitle = swSheet.TitleBlock()

       

      Dim note_count As Integer

      'note_count = swTitle.GetNoteCount()         '<<<<<<<If made active, its also giving the same error

       

      Dim vNote As SldWorks.Note

      'ReDim vNote(note_count)

      Set vNote = swTitle.GetNotes                     '<<<<< Here i am having the problem. The return type is array of notes, even i make it array of note, gives me error.

       

      'Dim i As Integer

      'Dim note_name As String

      'Dim note_text As String

      'For i = 0 To UBound(vNote)

      '    Dim swNote As SldWorks.Note

      '    Set swNote = vNote(i)

      '    note_name = swNote.GetName()

      '    note_text = swNote.GetText()

      'Next i

      End Sub