![]() |
#9
|
|||
|
|||
![]()
Hi,
I've done! I think , I've used a sledgehammer to kill a fly. But It works. Thanks anyway. Marc My code is: Code:
Private Sub Miseenforme_Click() 'Declare variables Dim outputStr As String Dim line1 As String Dim lineX As String Dim lineX_1 As String Dim lineX_2 As String Dim lineX_3 As String Dim endChar As String Dim numOfLines As Integer Dim rngTemp As Range 'Count the number of non blank lines in current document numOfLines = ActiveDocument.BuiltInDocumentProperties("NUMBER OF LINES") 'Move to start of document Selection.HomeKey Unit:=wdStory 'Move to start of line Selection.HomeKey Unit:=wdLine 'Select entire line and copy into variable currLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend line1 = "AN " & Selection.Range.Text Selection.Delete Selection.MoveDown Unit:=wdLine, Count:=(numOfLines - 5) Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend lineX_3 = "AC " & Selection.Range.Text Selection.Delete ' Selection.MoveDown Unit:=wdLine, Count:=1 Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend lineX_2 = "AH " & Selection.Range.Text Selection.Delete Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend lineX_1 = Selection.Range.Text Selection.Delete ' Selection.MoveDown Unit:=wdLine, Count:=2 Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend lineX = "AL " & Selection.Range.Text Selection.Delete 'past line1 + AN Set rngTemp = ActiveDocument.Range(Start:=0, End:=0) With rngTemp .InsertBefore line1 .InsertAfter lineX_3 .InsertAfter lineX_2 .InsertAfter lineX End With End Sub Last edited by macropod; 03-10-2013 at 06:23 PM. Reason: Added code tags & formatting |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
iiiiifffff | Word VBA | 16 | 06-04-2016 01:47 AM |
Macro to find text in between two characters and then format selected text? | qcom | Word | 5 | 02-19-2015 11:23 PM |
![]() |
simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |
![]() |
vsempoux | Word VBA | 3 | 10-31-2009 08:58 AM |
Mail merge Field Code Manipulation | macjnr | Mail Merge | 0 | 09-10-2009 11:37 AM |