p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

vba_word thread: Urgent Help needed (MSWORD)


Message #1 by "Dipak Goyal" <dipak.in@n...> on Wed, 24 Apr 2002 13:40:36 +0530
This is a multi-part message in MIME format.

------=_NextPart_000_0032_01C1EB95.9D29C7A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Sir,

I want to keep two lines blank in the starting and end of each page in a 
Ms Word document and the last two lines of the page should be kept blank 
after a comma(,) or a fullstop(.). If a blank line already exits, then 
don't enter a new blank line.

I'd be truly greatful if somebody could help me out. I've written a code 
but it only puts 2 blank lines at the start and end but if the document 
has lines in between then it doesn't work as I want.
regards,

Dipak Goyal

The code goes like this:

Sub Macro2()

On Error GoTo dip
'To get the current page...
Selection.Fields.Add Range:=3DSelection.Range, Type:=3DwdFieldPage
Selection.Fields.Update
Selection.MoveLeft Unit:=3DwdWord, count:=3D1, Extend:=3DwdExtend
d =3D Selection.Fields(Selection.Fields.count).Result
Selection.Fields(Selection.Fields.count).Delete

Dim co As Integer
Dim total As Integer
co =3D 56
'    wdinfo =3D Word.WdInformation.wdNumberOfPagesInDocument
    msg =3D "Enter Total Number of Pages "
    total =3D InputBox(msg)
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.MoveDown Unit:=3DwdLine, count:=3D52
If d =3D total Then
End
Else
  Do Until d =3D total
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.MoveDown Unit:=3DwdLine, count:=3Dco - 2
    Selection.MoveUp
    Selection.MoveUp
    d =3D d + 1
   End If
  Loop
  End If
Exit Sub
dip:
    MsgBox Err.Description
End Sub






  Return to Index