Results 1 to 5 of 5

Thread: Delete Whole Line [Resolved]

  1. #1

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Angry Delete Whole Line [Resolved]

    Hi all im trying to delete a whole line in a document if a element of an array has no value

    my code at present just place "46" there due to me using VBKeyDelete, so what do i do to replace the ,marker by completley deleting the line???




    VB Code:
    1. 'Loop Through the array placing in the address info
    2.     For intLoop = 1 To UBound(vntAddress)
    3.         'See if the Array elemnt has a value
    4.         If Len(vntAddress(intLoop)) Then
    5.             objRange.Find.Execute FindText:="<Address Line " & intLoop & ">", Forward:=True, _
    6.                 replacewith:=vntAddress(intLoop), Replace:=wdReplaceAll
    7.         Else
    8.             objRange.Find.Execute FindText:="<Address Line " & intLoop & ">", Forward:=True, _
    9.                 replacewith:=vbKeyDelete, Replace:=wdReplaceAll
    10.         End If 'Len(vntAddress(intLoop))
    11.     Next 'intloop

    Thanks

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Replace the line with "" instead of the vbdelete key.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667
    thanks mate thought of that just leveas a blank space i wish to physically remove the line if there is no information to place within it.

    thanks anyway

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    once the selection is on the right line, you can use this:
    VB Code:
    1. wdApp.Selection.Expand wdLine
    2.   wdApp.Selection.Delete Unit:=wdCharacter, Count:=1
    I'm not sure if you can replace wdApp.Selection with objRange

  5. #5

    Thread Starter
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667
    Thanks SI great works a treat

    VB Code:
    1. 'Loop Through the array placing in the address info
    2.         For intLoop = 1 To UBound(vntAddress)
    3.             'See if the Array elemnt has a value
    4.             If Len(vntAddress(intLoop)) Then
    5.                 objRange.Find.Execute FindText:="<Address Line " & intLoop & ">", Forward:=True, _
    6.                     replacewith:=vntAddress(intLoop), Replace:=wdReplaceAll
    7.             Else
    8.                  objRange.Find.Execute FindText:="<Address Line " & intLoop & ">", Forward:=True ', _
    9.                     'replacewith:="", Replace:=wdReplaceAll
    10.                     objRange.Select
    11.                       Application.Selection.Expand wdLine
    12.                       Application.Selection.Delete Unit:=wdCharacter, Count:=1
    13.  
    14.             End If 'Len(vntAddress(intLoop))
    15.         Next 'intloop

    THANKS!!!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width