Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Spiro - 10 Nov 2006 15:29 GMT
Hi,

I am totally worthless in Scripting/VBS I am wondering if someone would be
able to but these 2 scripts togheter.

1st Script:

Public Sub BatchTEST2()

Dim FirstLoop As Boolean
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
Dim Response As Long
Dim i As Long

PathToUse = "C:\Test\"

'Error handler to handle error generated whenever
'the FindReplace dialog is closed

On Error Resume Next

'Close all open documents before beginning

Documents.Close SaveChanges:=wdPromptToSaveChanges

'Boolean expression to test whether first loop
'This is used so that the FindReplace dialog will
'only be displayed for the first document

FirstLoop = True

'Set the directory and type of file to batch process

With Application.FileSearch
  .NewSearch
  .LookIn = PathToUse
  .SearchSubFolders = True
  .FileName = "*.rtf"
  .MatchTextExactly = True
  .FileType = msoFileTypeAllFiles

   If .Execute() Then

       For i = 1 To .FoundFiles.Count

           'Open document
           Set myDoc = Documents.Open(.FoundFiles(i))

           If FirstLoop Then

               'display dialog on first loop only

               Dialogs(wdDialogEditReplace).Show

               FirstLoop = False

               Response = MsgBox("Do you want to process " & _
               "the rest of the files in this folder", vbYesNo)
               If Response = vbNo Then Exit Sub

           Else

               'On subsequent loops (files), a ReplaceAll is
               'executed with the original settings and without
               'displaying the dialog box again

               With Dialogs(wdDialogEditReplace)
                   .ReplaceAll = 1
                   .Execute
               End With

           End If

           'Close the modified document after saving changes
           myDoc.Close SaveChanges:=wdSaveChanges

       Next i

   End If

End With

End Sub

Script 2:

Sub GOODONE()
'
' GOODONE Macro
'
   With ActiveDocument.Styles(wdStyleNormal).Font
       If .NameFarEast = .NameAscii Then
           .NameAscii = ""
       End If
       .NameFarEast = ""
   End With
   With ActiveDocument.PageSetup
       .LineNumbering.Active = False
       .Orientation = wdOrientLandscape
       .TopMargin = InchesToPoints(0.5)
       .BottomMargin = InchesToPoints(0.5)
       .LeftMargin = InchesToPoints(0.5)
       .RightMargin = InchesToPoints(0.5)
       .Gutter = InchesToPoints(0)
       .HeaderDistance = InchesToPoints(0.5)
       .FooterDistance = InchesToPoints(0.5)
       .PageWidth = InchesToPoints(11)
       .PageHeight = InchesToPoints(8.5)
       .FirstPageTray = wdPrinterDefaultBin
       .OtherPagesTray = wdPrinterDefaultBin
       .SectionStart = wdSectionNewPage
       .OddAndEvenPagesHeaderFooter = False
       .DifferentFirstPageHeaderFooter = False
       .VerticalAlignment = wdAlignVerticalTop
       .SuppressEndnotes = False
       .MirrorMargins = False
       .TwoPagesOnOne = False
       .BookFoldPrinting = False
       .BookFoldRevPrinting = False
       .BookFoldPrintingSheets = 1
       .GutterPos = wdGutterPosLeft
   End With
   Selection.WholeStory
   Selection.Font.Name = "Courier New"
   Selection.Font.Size = 8
End Sub

Option Explicit

Thanks alot,

George S.
Doug Robbins - Word MVP - 11 Nov 2006 00:38 GMT
It's probably easier if you tell us what it is intended to do rather than
force us to have to deduce that by interpreting your code.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi,
>
[quoted text clipped - 130 lines]
>
> George S.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.