Word Line Breaks in a vbscript string

H

hals_left

I have the following code to try and include line breaks in data being
passed ms word from a webpage. the problem is that because the
automation is done on the client, the line breaks are rendering in the
html giving scripts errors.

any ideas?
thanks
hals_left


' COM
Function AddressLabel()
AddressLabel=address1 & vbCrLF & address2
End Function


' ASP / Client-side VBScript
objRange.Find.Replacement.Text = "<%=objCustomer.AddressLabel%>"
 
H

hals_left

This still has me stumpted - is there any way to pass line breaks to
MS Word using vbscript not VBA?

I have a workaround where each line of the address is passed
individually, replacing predefined text in the word template; LINE_1,
LINE_2 etc. The problem is that some addresses have 4 lines, some have
3 etc. With the single function this could be checked and the address
lines / carriage returns adjusted.

Is there any way to use replace to remove a line of text in word
document ?
Thanks
hals_left
 
C

Cindy M -WordMVP-

Hi Hals_left,
This still has me stumpted - is there any way to pass line breaks to
MS Word using vbscript not VBA?

I have a workaround where each line of the address is passed
individually, replacing predefined text in the word template; LINE_1,
LINE_2 etc. The problem is that some addresses have 4 lines, some have
3 etc. With the single function this could be checked and the address
lines / carriage returns adjusted.

Is there any way to use replace to remove a line of text in word
document ?
I'm not really familiar with working from a web environment, nor vbscript, so
I'm not sure I can help. I'm not even entirely clear on what your problem is.
I do understand that you want to pass data to a Word document, and that this
information extends over multiple (3 - 4) paragraphs. Apparently the problem
is the vbCR? Is it that this is not being correctly recognized when you try to
use it as the Replacement.Text? In that case, try using ^p (the literal Word
Find/Replace equivalent of a paragraph mark) instead of vbCR.

address1^paddress2

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
H

hals_left

that works perfectly,thank-you!

The literal codes are very handy, as vb constants and html codes are
not recognised by ms word, do you know where I can find a list of
them?

thanks
hals_left
 
C

Cindy M -WordMVP-

Hi Hals_left,
The literal codes are very handy, as vb constants and html codes are
not recognised by ms word, do you know where I can find a list of
them?
Not as a single list, no. But all of them are available through any
Office application's Object Browser (go into the VB Editor, the press
F2). Or, if you're just looking for one, in particular, you can type
it into the VB Editor's Immediate window (Ctrl+G): ?wdStyleNormal
[ENTER] and on the next line you'll get the literal.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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