Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2014, 07:57 AM
nsyrax nsyrax is offline Help with VBA script Windows 7 64bit Help with VBA script Office 2010 64bit
Novice
Help with VBA script
 
Join Date: Jan 2014
Posts: 1
nsyrax is on a distinguished road
Default Help with VBA script

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
Reply With Quote
  #2  
Old 01-18-2014, 03:38 AM
macropod's Avatar
macropod macropod is offline Help with VBA script Windows 7 32bit Help with VBA script Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with VBA script 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
Help with VBA script 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:26 AM.


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