Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 03-10-2013, 10:18 AM
srt srt is offline Text manipulation in MACRO Windows 8 Text manipulation in MACRO Office 2010 64bit
Novice
Text manipulation in MACRO
 
Join Date: Mar 2013
Location: Glasgow, UK
Posts: 15
srt is on a distinguished road
Default

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
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text manipulation in MACRO Macro to find text and replace with form field containing that text 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
Text manipulation in MACRO Need help on Macro 03- Find text - if text is blank then remove line simpleonline1234 Word VBA 1 02-25-2011 02:28 AM
Text manipulation in MACRO Combobox manipulation 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:14 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft