Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2003

Tip: Looking for answers? Try searching our database.

Word interop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Curls - 09 Sep 2003 09:53 GMT
Hi all!
I'm using the "Microsoft Word 9.0 Object Library" to
interact with Word inside a WebService. I would like to
get the plain text of a Word document:

object one = (int)1;
string result = _app.Documents.Item(ref one).Content.Text;

this works fine, but if the original document is based on
a template, it returns also the structure of the template
(like "\* MERGEFORMAT "). How can I get the plain text?

Thanks in advance!

AR
Cindy Meister  -WordMVP- - 09 Sep 2003 19:20 GMT
Hi Curls,

> I'm using the "Microsoft Word 9.0 Object Library" to
> interact with Word inside a WebService. I would like to
[quoted text clipped - 6 lines]
> a template, it returns also the structure of the template
> (like "\* MERGEFORMAT "). How can I get the plain text?

\* MergeFormat has nothing to do with a template. That would
be part of a field code. And I'm a bit at a loss why a field
code would be coming across when you request the .Text
property. But...

1. Declare a range variable and set it to the document
range. Roughly:
Dim rng as Word.Range = _app.Documents.Item(re one).Range

Then set the TextRetrievalMode to NOT include field codes:

rng.TextRetrievalMode.IncludeFieldCodes = False

See then if rng.Text returns something else than you're
currently getting.

Note: if you're gettin all kinds of weird things, such as
style names, double-check the file format being used to OPEN
the document. It's remotely possible that it's being opened
with "Recover text from any document".

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
curls - 10 Sep 2003 07:49 GMT
It works fine!
Thanks a lot Cindy!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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.