Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: MS Word Macro


Message #1 by "dipak goyal" <dipak.in@n...> on Mon, 29 Apr 2002 11:00:31
Hi!,
I want to add Two Blank Lines at starting and end of each page in a Ms 
Word 
document. The margins are pre-set.

The code that I've written can insert two blank lines, but only when the 
whole
doucment is merged together. It doesn?t work with paragraphs( 0 or more). 
The code goes like this:

Sub Macro2()
On Error GoTo dip
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage
Selection.Fields.Update
Selection.MoveLeft unit:=wdWord, count:=1, Extend:=wdExtend
d = Selection.Fields(Selection.Fields.count).Result
Selection.Fields(Selection.Fields.count).Delete
Dim co As Integer
Dim total As Integer
co = 56
'    wdinfo = Word.WdInformation.wdNumberOfPagesInDocument
    msg = "Enter Total Number of Pages "
    total = InputBox(msg)
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.MoveDown unit:=wdLine, count:=52
If d = total Then
End
Else
  Do Until d = total
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.MoveDown unit:=wdLine, count:=co - 2
    Selection.MoveUp
    Selection.MoveUp
    d = d + 1
  Loop
  End If
Exit Sub
dip:
    MsgBox Err.Description
End Sub

regards,
Dipak Goyal


  Return to Index