|
-
Nov 20th, 2000, 04:45 AM
#1
Hello,
I have a tiny problem.
I'm merging clientadresses from a database into word.
There's no problem until Word-document becomes Visible.
Only the last field is visible.
I need to insert a pagebreak or a space between the fields, but i don't know how to do that.
Can anyone help me?
I have inserted the code so it is a litlle bit more clear.
Dim myWrd As Word.Document
Dim myMerge As Word.MailMerge
Dim AppWord As Word.Application
Set AppWord = New Word.Application
Set myWrd = AppWord.Documents.Add
Set myMerge = myWrd.MailMerge
With myMerge
.Application.Visible = True
.OpenDataSource Name:=Replace(Get_ReportAdres, "Project BH\CrystalReports", "Databases\Boekhouden.mdb"), Connection:=gConn, SQLStatement:="SELECT Naam, Straat, PostCode, Gemeente FROM AfdLijsten"
.Fields.Add Range:=myWrd.Range, Name:="Naam"
'space or break?
.Fields.Add Range:=myWrd.Range, Name:="Straat"
'space or break?
.Fields.Add Range:=myWrd.Range, Name:="PostCode"
'space or break?
.Fields.Add Range:=myWrd.Range, Name:="Gemeente"
'space or break?
.Execute
myWrd.Close wdDoNotSaveChanges
End With
-
Nov 20th, 2000, 05:49 AM
#2
I've been looking at MSWord 97 here, so this may differ a little bit. First, you might need to have this line added to enable pagebreaks:
ActiveDocument.Tables(2).AllowPageBreaks = True
Code is :
Code:
Selection.InsertBreak Type:=wdPageBreak
I see what you mean, in the help files or internet there is nothing on this, I always find it helpful to cheat slightly... 
- [1] Goto tools menu, create a new macro
[2] Manually run the procedure - i.e. in this case, insert, pagebreak option
[3] Start the visual basic editor (press alt+F11)
[4] Look up the code created under the normal project and modules folder
Hope this helps you! If you need this for word 97 if the above doesn't work, I can look at home for you, just post here again.
[Edited by alex_read on 11-20-2000 at 05:51 AM]
-
Nov 20th, 2000, 07:42 AM
#3
Thank you very much alex_read.
The problem isn't solved yet. I'm working with Word 2000 and I'm still trying to figger the mailmerge out.
But the tip about the macro's is fantastic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|