| View previous topic :: View next topic |
| Author |
Message |
fluxpunk General User

Joined: 10 Feb 2006 Posts: 19
|
Posted: Wed Jul 19, 2006 3:06 am Post subject: Problem using '&' and find replace in open office/vb.net |
|
|
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 |
|
 |
Zarius OOo Enthusiast


Joined: 21 Jan 2005 Posts: 142 Location: Brisbane, Australia
|
Posted: Wed Jul 19, 2006 8:31 pm Post subject: |
|
|
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 |
|
 |
Zarius OOo Enthusiast


Joined: 21 Jan 2005 Posts: 142 Location: Brisbane, Australia
|
Posted: Wed Jul 19, 2006 8:38 pm Post subject: |
|
|
Actually, after a quick modification of the code I ran it under Basic, changed the "oRD.searchRegularExpression" value to false and it works
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 |
|
 |
|