OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Problem using '&' and find replace in open office/vb.net

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
fluxpunk
General User
General User


Joined: 10 Feb 2006
Posts: 19

PostPosted: Wed Jul 19, 2006 3:06 am    Post subject: Problem using '&' and find replace in open office/vb.net Reply with quote

hi i have a vb.net 2003 application where a user can type in a name and an address of a client and then they click a button and the program performs a find and replace on an open office document.

The text to find for the clients name is <clientname> and it should replace it with the clients name(e.g Mr & Mrs Smith) The problem i have is when i use ampersand & it replaces the & with <clientname> and i get this output

Mr <clientname> Mrs Smith

I dont know wether this is a vb problem or a open office problem here is my code




Code:
 


       oSM = CreateObject("com.sun.star.ServiceManager")
        oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
        oDoc = oDesk.loadComponentFromURL("file://server/Company%20Programs/contract/docs/" & fileName, "_blank", 0, New unoidl.com.sun.star.beans.PropertyValue(0) {})

        If Me.rbtEstimate.Checked = True Then
            displayQuote()
        End If

        numWord(txtPrice.Text)

        oRD = oDoc.createReplaceDescriptor
        oRD.searchRegularExpression = True


        'find/replace clients name
        oRD.setSearchString("<clientname>")
        oRD.setReplaceString(txtClientName.Text)
        oDoc.replaceall(oRD)
[/code]
Back to top
View user's profile Send private message
Zarius
OOo Enthusiast
OOo Enthusiast


Joined: 21 Jan 2005
Posts: 142
Location: Brisbane, Australia

PostPosted: Wed Jul 19, 2006 8:31 pm    Post subject: Reply with quote

I haven't used VB much, but it could have to do with the search being a regular expression - "oRD.searchRegularExpression = True" - try making it false and see if that works.

Otherwise I have some OpenOfficeBasic code which replaces "PlaceHolder" fields (this allows a little more flexibility, eg. allowing a shortcut key to jump from field to field) with whatever data you want (my program grabs the data from a database of businesses and contacts and replaces any relevant fields in a document or spreadsheet). I can post a snippet of that, or you can check out my program here.
_________________
Zarius Tularial. (WinXP - OOo 1.1.4, FedoraCore 4 - OOo 2.0, RHEL4 - StarOffice 7)
Quoots - a quicker way to open your documents and fill in template details in OOo. (written in OOBasic)
Back to top
View user's profile Send private message Visit poster's website
Zarius
OOo Enthusiast
OOo Enthusiast


Joined: 21 Jan 2005
Posts: 142
Location: Brisbane, Australia

PostPosted: Wed Jul 19, 2006 8:38 pm    Post subject: Reply with quote

Actually, after a quick modification of the code I ran it under Basic, changed the "oRD.searchRegularExpression" value to false and it works Smile

Still, you might want to check out my program ("Quoots") - we may be working toward similar goals. It could be a bit "heavy" - being a collection of a few different libraries (though they complement each other) - but I'm looking at modularising it and making it more flexible so any feedback is appreciated.
_________________
Zarius Tularial. (WinXP - OOo 1.1.4, FedoraCore 4 - OOo 2.0, RHEL4 - StarOffice 7)
Quoots - a quicker way to open your documents and fill in template details in OOo. (written in OOBasic)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group