Word Automation DocumentVariables

G

Gandalf

Hi,

Using Word 2000 and automating with VB

I am utilising Document variables to fill in data in a word document. all is
fine until I come to try and insert a multi line field i.e.

I have a field {DOCVARIABLE "Address" \* MERGEFORMAT}

and from vb I am setting the value as

Selection.Document.Variables("Address") = myObj.Address

The code in myObj is roughly

Public Function Address() as string
Address="1 The Street"
Address=Address & vbCrLf & "Some Town"
End Function

However in the resulting document vbCrLf is replaced with 'squares'

Anyone any idea how to make it wrap?


Cheers
 
J

Joanne

I run into the same problem...then I have to do a search
and replace for vbLf and replace with nothing
 
G

Gandalf

Hi all,

Thanks the CrLf was the problem although it was masked by the fact that the
field was in table cell and wou;d only do multiple lines if it was
terminated with a return

As a side issue I tried using Selection.Document.Variables("Address") =
CleanString(myObj.Address) but that sometimes failed with word saying it was
busy so I ended up using Selection.Document.Variables("Address") =
Replace(myObj.Address,vbLf,"")

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top