开发者

Can't insert newline in msword form field using Powebuilder OLE

I have an application written in Powerbuilder 11.5 that automatically fills in form fields of a Word document (MS Word 2003).

The Word document is protected so only the form fields can be altered.

In the code below you can see I use char(10) + char(13) to insert a newline, however in the saved document all I see is 2 little squares where the characters should be.

I've also tried using "~r~n", this also just prints 2 squares.

When I fill in the form manually I can insert newlines as much as I want.

Is there anything else I can try? Or does anybody know of a different way to fill in word forms using Powerbuilder?

//1 Shipper
ls_value = ids_form_info.object.shipper_name[1]

if not isnull(ids_form_info.object.shipper_address2[1]) then
 ls_value += ch开发者_如何学Goar(10) + char(13) + ids_form_info.object.shipper_address2[1]
end if

if not isnull(ids_form_info.object.shipper_address4[1]) then
 ls_value += char(10) + char(13) + ids_form_info.object.shipper_address4[1]
end if

if not isnull(ids_form_info.object.shipper_country[1]) then
 ls_value += char(10) + char(13) + ids_form_info.object.shipper_country[1]
end if

if lnv_word.f_inserttextatbookmark( 'shipper', ls_value ) = -1 then return -1

The f_inserttextatbookmark is as follows:

public function integer f_inserttextatbookmark (string as_bookmark, string as_text, string as_fontname, integer ai_fontsize);
if isnull(as_text) then return 0
    iole_word = create OLEOBJECT

    iole_word.connectToNewobject( "word.application" )

    iole_word.Documents.open( <string to word doc> )

 iole_word.ActiveDocument.FormFields.Item(as_bookmark).Result = as_text

return 1
end function


Part of your problem is that carriage return is char(13), and line feed is char(10), so to make a CRLF in Windows and DOS you usually need to make char(13) + char(10). If these are out of order, many programs will balk. However, "~r~n" should have produced that for you.

I have success with (and I'm converting for brevity so it might only be close to correct):

lole_Word.ConnectToNewObject ("Word.Application")
...
lole_Word.Selection.TypeText (ls_StringForWord)

Maybe you can try other Word OLE commands to see if it's something to do with the specific command. (After the definition of the line break, I'm grasping at straws.)

Good luck,

Terry


Sounds like it may be a Unicode/Ansi character conversion thing.

for what its worth you could try this ...

http://www.rgagnon.com/pbdetails/pb-0263.html

Hope it helps.


I'm not using form fields, but I am able to insert newlines into a Word document from PowerBuilder using TypeText and "~n". Maybe you just need "~n".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜