Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2006

Tip: Looking for answers? Try searching our database.

Search and replace my custom tags in WordML??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M O J O - 27 Jul 2006 13:01 GMT
Hi,

I need to open a wordml document and search/replace some custom tags.

The problem is, that when I open a wordml doc, the tags are messed up.

My text look likes this "Dear @customername@, ....", but when I open the
wordml doc, it can look like this....

<w:rPr>Dear <w:b/>@</w:rPr><w:t>customername</w:t>@</w:r>
or
<w:rPr>Dear <w:b/></w:rPr>@<w:t>customername@</w:t></w:r>
etc.

I want to keep the @ and unsername together like this...

<w:rPr>Dear <w:b/></w:rPr><w:t>@customername@</w:t></w:r>

Is that possible???

Thanks!

Mojo
Cindy M  -WordMVP- - 27 Jul 2006 16:10 GMT
Hi M,

> I need to open a wordml document and search/replace some custom tags.
>  
[quoted text clipped - 13 lines]
>  
> Is that possible???

I very much doubt that the WordML you're getting when you save a Word 2003
document looks like the samples you're showing us above. "Dear " would
certainly have to be within <w:t> tags; the @ as well. I'm guessing that
you may be formatting the customername characters differently than the
surrounding @? That would break up the text run...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :-)
M O J O - 27 Jul 2006 21:02 GMT
Hi Cindy,

My point was just to show that the '@' signs wasn't always together with
the customername. :o)

Let's say I want to load the xml file into Notepad and do a search and
replace (I don't want to use word to do the search and replace ... it
will be done on a computer that does not have word installed).

How can I make my own "tags" that will not be messed up by wordml-tags?

I want my user to create a word doc, type in text and add variables like
@customername@. Then my own .net application must open the xml file and
do a search and replace. Therefore the @customername@ must stick together.

Hope you understand what I mean.

This is a BIG problem for me. :o(

Thanks!

Mojo

Cindy M -WordMVP- skrev:
> Hi M,
>
[quoted text clipped - 29 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Dr. Eckehard Pfeifer - 28 Jul 2006 13:37 GMT
Hi, I dont know, If I understand you correctly. Whats about your own
namespace concerning the parameters you signed as @parameter@? Like
<param xmlns="myNamespace">value</param>.

Signature

MfG EP
Entwicklung - Beratung - Training (www.dr-e-pfeifer.net)
(Microsoft Certified Application Developer)
neu: MS Office 2003 - Das Entwicklerbuch (ISBN 3-86063-688-X)

Cindy M  -WordMVP- - 28 Jul 2006 15:26 GMT
Hi Mojo,

But you see, on my machine the @ signs aren't separated from the rest of the
text. Unless I format them differently or use Insert/Symbol. So it would be
important for you to show us EXACTLY what the problem is that you're
encountering - the WordML you're struggling with.

> My point was just to show that the '@' signs wasn't always together with
> the customername. :o)
[quoted text clipped - 12 lines]
>  
> This is a BIG problem for me. :o(

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :-)
M O J O - 31 Jul 2006 06:23 GMT
Hi Cindy,

I want my user to write a "template" in word and save it as xml. This
template will later be used for our own mailmerge system.

Therefore if my users open a new document and enters the field
@customoername@, the wordml will look like this...

...<w:p><w:r><w:t>@customername@</w:t></w:r>....

This is very easy to open the xml file in our .net-crm application and
do a search/replace on the variable @customername@.

But if the user wants to make it bold and by mistake forgets to
highlight the last @, the wordml will look like this...

<w:rPr><w:b/></w:rPr><w:t>@customername</w:t></w:r><w:r><w:t>@</w:t>

Then I will not be able to from my .net-crm application to open the word
as a tectfile and do a search/replace on the @customername@, because
it's now called...

@customername</w:t></w:r><w:r><w:t>@

I would like my users to be able to enter a fieldname like @customernam@
in word and no matter what formatting they do on the field, the
@customername@ must be intact.

Hope you get what I mean.

:o)

Thanks for still trying to help me out here!!

Mojo

Cindy M -WordMVP- skrev:
> Hi Mojo,
>
[quoted text clipped - 27 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Peter Jamieson - 31 Jul 2006 09:15 GMT
I don't believe there is any way you can force Word to fix this at the point
when you save the document, unless you know how to write a transform that
could do it (I don't), particularly...

> I would like my users to be able to enter a fieldname like @customernam@
> in word and no matter what formatting they do on the field, the
> @customername@ must be intact.

...when you want that much flexibility. What you're implying is that there
could be any number of formatting tags within the @customername@ "tag". Nor
is it going to be simple even to identify what is and what is not a tag,
partly because a character such as "@" is quite likely to be used in other
ways in a document (especially in e-mail addresses), and partly because the
user may accidentally omit an "@".

Personally I would consider two approaches to solving this:
a. either provide a macro that the user either invokes or is invoked
automatically when the document is closed, or can be run as a check after
closing, to go through the document looking for @tag@ tags, reporting on any
"solitary" "@" characters it can find, then applying (or more likely,
removing) consistent formatting, in a way that you have determined by
experiment leaves you with <w:t>@tag@</w:t>
b. or postprocess the resulting XML, using any appropriate language, in a
three-stage process:
  - make a copy of the XML and strip all XML tags so that the user-defined
@tag@ tags are reconstituted
  - perform much the same checking for "solitary" "@" chaaracters as in (a)
and flag any stuff you cannot recognise
  - if all is OK, reprocess the original XML by identifying the start and
end of @tag@ tags and successively swapping the positions of XML tags and
plain text until the @tag@ is reconsituted.

If (a) is feasible, it looks an awful lot simpler to me than (b).  I also
suspect it might be a whole lot more reliable if you didn't use a common
character such as "@" as your tag marker, or doubled it up to @@. Personally
I like "¬" (who on earth uses that?), but that's primarily because it's
available on a UK keyboard. Of course th logical problem remains whatever
you use.

Peter Jamieson

> Hi Cindy,
>
[quoted text clipped - 57 lines]
>> This reply is posted in the Newsgroup; please post any follow question or
>> reply in the newsgroup and not by e-mail :-)
Cindy M  -WordMVP- - 31 Jul 2006 11:12 GMT
Hi Mojo,

I get what you mean. And I agree with Peter's analysis.

The only additional thought I have is that it should be possible to use
XPath rather than a text search. XPath should let you extend what's picked
up until you hit the "end symbol", and to pick up only the <t> tag's
contents. As long as you're using XML, make the most of it and use the
tools that are available for working with it :-) XML wasn't designed to be
worked with in "text editor"...

> I want my user to write a "template" in word and save it as xml. This
> template will later be used for our own mailmerge system.
[quoted text clipped - 23 lines]
>  
> Hope you get what I mean.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :-)
M O J O - 31 Jul 2006 20:45 GMT
Hi Peter and Cindy,

Thank you both for the elaborating answers.

I will try to parse the file as an xml file.

Thanks again!!

Mojo

M O J O skrev:
> Hi Cindy,
>
[quoted text clipped - 63 lines]
>> This reply is posted in the Newsgroup; please post any follow question
>> or reply in the newsgroup and not by e-mail :-)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.