![]() |
|
|
|
#1
|
|||
|
|||
I have a .txt file that needs to be cleaned up. It needs to have a page break before the word "Individual" on every page. It also needs to be Courier New 8.5pts, top and bottom margin of 0.5in, left and right margin of 1in. I modified another script I found (shown below) and it almost gets me there. the problem is there is some unneeded text before "Individual", which is the number 1 followed by several spaces and 3 carraige returns. I need to delete this text. Below is the script as it is currently:Code:
Sub InsertPageBeforeDate()
Dim lngPos As Long
Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Font.Name = "Courier New"
Selection.Font.Size = 8.5
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "Individual"
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
Do While .Execute
If Selection.Information(wdFirstCharacterLineNumber) > 1 Then
lngPos = Selection.Start
Selection.MoveLeft Unit:=wdWord, Count:=2, Extend:=True
If LCase(Selection.Text) <> "of " Then
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertBreak Type:=wdPageBreak
End If
ActiveDocument.Range(Start:=lngPos + 4, End:=lngPos + 4).Select
End If
Loop
End With
Application.ScreenUpdating = True
End Sub
|
|
#2
|
||||
|
||||
|
Cross-posted at: http://www.eileenslounge.com/posting...y&f=26&t=15255
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184 You also need to be aware of the fact plain text files cannot contain formatting or page layout information, including font types/sizes, page orientation & margins.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Outlook Script Help
|
TheInfinetGroup | Outlook | 1 | 03-02-2013 07:43 AM |
| Add Shared Calendar using script | Antros | Outlook | 0 | 03-15-2012 01:01 PM |
Script Doesn't works on other machine
|
ravininave | Word | 1 | 01-05-2011 01:45 PM |
| [ask] about VB Script + Ms. Project | anak_baru | Project | 2 | 03-10-2009 01:42 AM |
Print error OE6- script line 1344
|
HJJC | Outlook | 11 | 12-10-2005 09:43 AM |