LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Insert Pagebreak in Word document

I have this code

Sub Flet()
Dim Wdapp As Object
Dim Navn As String
Dim Adr As String
Dim PostnrBy As String

On Error Resume Next
Set Wdapp = GetObject(, "Word.application")
If Err.Number < 0 Then
Set Wdapp = CreateObject("Word.Application")
End If
Wdapp.Documents.Add
For Each c In Range("A2:A20")

If c.Value = "" Then Exit For Else
Navn = c.Value
Adr = c.Offset(0, 1).Value
PnrBy = c.Offset(0, 2).Value & " " & c.Offset(0, 3).Value

Wdapp.Selection.TypeText Text:=Navn
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeText Text:=Adr
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeText Text:=PnrBy
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeParagraph
Wdapp.Selection.TypeText Text:="Dear " & Left(Navn, InStr(1,
Navn, " "))
Wdapp.Selection.TypeParagraph
Wdapp.Selection.InsertBreak Type:=wdPageBreak
Next c
Wdapp.Visible = True
Wdapp.Activate
Set Wdapp = Nothing

End Sub

And it works perfectly Ok, except for the pagebreak, that I would like to
appear after the line Dear ... The line Wdapp.Selection.InsertBreak
Type:=wdPageBreak is apparently ignored. Is there any other way I could
insert a pagebreak in my document, so the next run of trhe For Each...Next
loop is done on a new page?

Jan



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert a word document onto an Excel Chart rb22 Excel Discussion (Misc queries) 1 June 16th 09 06:04 PM
Insert Word Document Mike H. Excel Discussion (Misc queries) 1 October 30th 08 07:16 PM
Insert pagebreak when a specific word appears in a column. Neal Excel Discussion (Misc queries) 4 October 27th 08 11:17 PM
Insert Word Document into Excel Steve Blake Excel Discussion (Misc queries) 2 July 5th 07 12:10 PM
Insert Excel hyperlink to word document BHalberstater Excel Worksheet Functions 0 April 26th 06 08:54 AM


All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"