Consulting

Results 1 to 2 of 2

Thread: Delete single procedures

  1. #1
    VBAX Mentor XL-Dennis's Avatar
    Joined
    May 2004
    Location
    ?stersund, Sweden
    Posts
    499
    Location

    Delete single procedures

    Hi all

    Below You find the approach I use in Excel "converted" to Word to delete single procedures (it use early binding to Microsoft Visual Basic for Applications Extensibility 5.3)

    [vba]
    Option Explicit
    Sub Delete_Procedure()
    Dim wdDoc As Document
    Set wdDoc = ActiveDocument
    Dim vbaProject As VBIDE.VBProject
    Dim vbaModule As VBIDE.VBComponent
    Dim vbacdModule As VBIDE.CodeModule
    Set vbaProject = wdDoc.VBProject
    Set vbaModule = vbaProject.VBComponents("ThisDocument")
    Set vbacdModule = vbaModule.CodeModule
    With vbacdModule
    .DeleteLines .ProcStartLine("Test", 0), .ProcCountLines("Test", 0)
    End With
    Set vbacdModule = Nothing
    Set vbaModule = Nothing
    Set vbaProject = Nothing
    End Sub
    [/vba]

    Is the above an acceptable way when working in Word?

    TIA,
    Dennis
    Last edited by Zack Barresse; 06-22-2004 at 10:12 AM.
    Kind regards,
    Dennis

    ExcelKB | .NET & Excel | 2nd edition PED


  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Yes. It works well.

    As you note, it requires that VBA Extensibility be referenced, other wise this will not work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •