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 / March 2005

Tip: Looking for answers? Try searching our database.

Range.Text - Generic Server Exception using Word Interop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jareddunne@gmail.com - 25 Feb 2005 23:50 GMT
Hello All-

I wrote a ASP.NET web service for automating Word document creation
based on WordML templates. I have this all working using Word Interop's
Find and Replace funtionality to replace my placeholder text from the
template document with the actual data from my database.

We were hoping to increase performance by using Bookmarks to mark the
range fo the placeholders... I found this article on MSDN which make it
seem very straight forward and perfect for what we want:
<a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/
wrtskhowtoupdatebookmarktext.asp">How

to Update Bookmark Text</a>

I actually copied and pasted the exact final method from the article to
use in my code. When I called the method (after confirming with
Document.Bookmarks.Exists( bookmarkname ) that the bookmark exists), I
get a "Server threw an exception" exception on the line "rng.Text =
newText", noted below:

internal void BookMarkReplaceRange(string bookmarkName, string newText)

{
   object missingValue = Type.Missing;
   object oBookmarkName = bookmarkName;
   Word.Range rng = ThisDocument.Bookmarks.get_Item(
       ref oBookmarkName).Range;
   rng.Text = newText; //Error here
   object oRng = rng;
   ThisDocument.Bookmarks.Add(bookmarkName, ref oRng);
}

This is the error:
System.Runtime.InteropServices.COMException (0x80010105): The server
threw an exception.
at Microsoft.Office.Interop.Word.Range.set_Text(String prop)
....

Anyone know why this MSDN code sample isnt working?

Why is the error so vague?

*cries* How do i make it work?...

Thanks inadvance!
Jared-
jareddunne@gmail.com - 25 Feb 2005 23:56 GMT
Preemptive answers:
- No, this is not the exception my web service throws, if i wrap that
line with a try/catch that's the exception i get.
- Yes, my bookmark starting directly before the placeholder (ie:
@AttorneyName@) and ending directly after it... so No, I am not
spanning formatting tags or anything crazy.
- Yes, dynamically adding my bookmarks around the placeholder using the
Word Interop API, yields same error.
Cheri Reed - 30 Mar 2005 20:23 GMT
I'm having the same problem... did you find an answer?

> Preemptive answers:
> - No, this is not the exception my web service throws, if i wrap that
[quoted text clipped - 4 lines]
> - Yes, dynamically adding my bookmarks around the placeholder using the
> Word Interop API, yields same error.

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.