473,811 Members | 3,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET and MS Word Find and Replace Error

Hi. I am autoamtiacally creating a MS Word file through code. Most of
my code works, but when I try to do a find and replace, I get a
read/write memrory access error. Not sure what is going on. Any advice?
Error occurs on the .Text line of the with block

Public wordapp As New Microsoft.Offic e.Interop.Word. Application
Public doc As New Microsoft.Offic e.Interop.Word. Document

With wordapp.Selecti on.Find
.Text = "[" & Trim(strField) & "]"
.Replacement.Te xt = Trim(strReplace mentText)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLik e = False
.MatchAllWordFo rms = False
End With
wordapp.Selecti on.Find.Execute (Replace:=wdRep laceAll)

Dec 12 '06 #1
1 2522
"Jordan" <jo***********@ gmail.comwrote in message
news:11******** **************@ n67g2000cwd.goo glegroups.com.. .
Hi. I am autoamtiacally creating a MS Word file through code.
Public wordapp As New Microsoft.Offic e.Interop.Word. Application
Public doc As New Microsoft.Offic e.Interop.Word. Document
You would be strongly advised NOT to do this due to stability, performance
and scalability issues.

In fact, Microsoft themselves strongly advise against doing this and,
furthermore, will not support any application which does this:
http://support.microsoft.com/default...US;q257757#kb2

Creating a Word file in ASP.NET without automation is not particularly
difficult - choose one of the following options instead:

1) Create an HTML file and give it a .doc extension.

2) Create an XML Word file and give it a .doc extension - the XML schema for
Word (and other Office products) is readily available on the web

3) Use a 3rd-party product like this:
http://www.aspose.com/Products/Aspos...s/Default.aspx - while you're
there, click in the "Why Not Automation?" hyperlink...
Dec 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
6148
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there is one row containing picture(s) as well. So far, what I did is doing it manually for each word docs I have. Select Table Convert Table to Text(I use ^ character for delimiter)
0
2898
by: David Krmpotic | last post by:
Regards, I need a little explanation in converting word VB macros to charp code! first, I recorded simple macro which replaces every occurence of one word in whole document (is it?) , here: Sub replaceall() '
1
5333
by: adam lital | last post by:
Hi, I have word document and i want to replace a specific text with a bookmark using code. Example: in the document i have the text and i want to replace this to a bookmark called ClientName. Thanks, Adam.
1
5130
by: James Vitale | last post by:
Using vb asp.net 1.1 I'm doing a word automation on a doc file and trying to do a find and replace. My existing code works fine except that it doesn't find and replace in the header. My code to set the selection is as follows: 'This sets the selection to be the whole document
8
4218
by: John Salerno | last post by:
I figured my first step is to install the win32 extension, which I did, but I can't seem to find any documentation for it. A couple of the links on Mark Hammond's site don't seem to work. Anyway, all I need to do is search in the Word document for certain strings and either delete them or replace them. Easy enough, if only I knew which function, etc. to use. Hope someone can push me in the right direction.
1
5154
by: jordan.marton | last post by:
Hi. I am autoamtiacally creating a MS Word file through code. Most of my code works, but when I try to do a find and replace, I get a read/write memrory access error. Not sure what is going on. Any advice? Error occurs on the .Text line of the with block Public wordapp As New Microsoft.Office.Interop.Word.Application Public doc As New Microsoft.Office.Interop.Word.Document With wordapp.Selection.Find
2
5101
by: Ola K | last post by:
Hi guys, I wrote a script that works *almost* perfectly, and this lack of perfection simply puzzles me. I simply cannot point the whys, so any help on it will be appreciated. I paste it all here, the string at the beginning explains what it does: '''A script for MS Word which does the following: 1) Assigns all Hebrew italic characters "Italic" character style. 2) Assigns all Hebrew bold characters "Bold" character style. 2) Assign all...
4
12454
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
0
1012
by: asedt | last post by:
I have problem creating a private sub to replace text in a wordfile, is the use of ByRef good? The problem is that this works on my developing computer but not at the target computers. Private Sub Replace(ByRef WordApp As Word.Application, ByVal OLDText As String, ByVal NEWText As String) WordApp.Selection.Find.ClearFormatting() WordApp.Selection.Find.Text = OLDText ...
0
10652
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10408
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7673
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5561
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.