|
-
Nov 9th, 2005, 03:24 AM
#1
Thread Starter
Lively Member
Delete line in word
Hi, I have written a small macro that pulls data from excel to populate a letter with data (eg name, address, and some selected paragraphs). here is an example of my code:
VB Code:
wordarray = Array(addressline1, addressline2, addressline3, addressline4, postcode, Policynumber, Yourref, ourref, date, salutation, para1, para2, para3, para4, signed, position)
wrd.Activedocument.Fields(1).Select
With wrd.Selection
.InsertAfter Text:=Addressee
End With
For wrdroutine = 0 To 15
wrd.Selection.NextField.Select
With wrd.Selection
.InsertAfter Text:=wordarray(wrdroutine)
End With
Next
End
My problem is, sometimes para1 may not be applicable, and the same for the rest of the paragraphs. So I could have a letter that will have para2, para3 & para5. This will leave blank spaces were para1 & para4 are. Is there a way so that if para = "" (in this case para1 & para4) then it will delete that line where that are supposed to be input and the one below to bring the text up so there will not be 3 blank lines between the next paragraph entere don the letter?
I hope this makes sense!
many thanks
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Nov 9th, 2005, 04:25 AM
#2
Re: Delete line in word
I'm not quite sure how your code works (I assume you have a number of fields in a document, but I don't know what the fields are). Anyway...
In your For Next loop can you do
VB Code:
Set f = wrd.Selection.NextField
If wordarray(wrdroutine) = "" Then f.Delete
This world is not my home. I'm just passing through.
-
Nov 9th, 2005, 07:29 AM
#3
Thread Starter
Lively Member
Re: Delete line in word
thanks for that, will give that ago, not sure where to fit it in, but will try! thanks
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
-
Nov 9th, 2005, 07:40 AM
#4
Re: Delete line in word
VB Code:
wordarray = Array(addressline1, addressline2, addressline3, addressline4, postcode, Policynumber, Yourref, ourref, Date, salutation, para1, para2, para3, para4, signed, position)
wrd.Activedocument.Fields(1).Select
With wrd.Selection
.InsertAfter Text:=Addressee
End With
Dim f As Field
For wrdroutine = 0 To 15
Set f = wrd.Selection.NextField
wrd.Selection.NextField.Select
With wrd.Selection
If wordarray(wrdroutine) = "" Then
f.Delete
Else
.InsertAfter Text:=wordarray(wrdroutine)
End If
End With
Next
End
This world is not my home. I'm just passing through.
-
Nov 11th, 2005, 06:06 AM
#5
Thread Starter
Lively Member
Re: Delete line in word
thanks alot, much appreciated
The Box Said: "You need Windows Vista or better" ... So I Installed LiNUX 
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
|