Experts Please respond.. WORD on server side, multithreading and q

R

Rama

Hello,
I'm trying to parse a word document using .NET and VBA and its
taking more than 5 minutes to strip off tables,images and text values. if the
word document has more than 20 pages then its taking more time. I'm using
clipborad functionality to copy the images and converting plain text into
Rich text so User can't work with copy and paste functionality at the same
time. For this purpose they wanted to run this document on server but my
question here is word isn't capable of running in multithreading or queue
modes. Can anyone throw some light to my problem?

1) Clipborad is causing problems at client place if they are working with
copy\paste functionality at the same time.

2) Can I apply mutithreading concept on word?
 
T

Tony Jollans

I'm not entirely sure I follow what you want, but if you include "DoEvents"
regularly in your code it should effectively simulate multithreading and the
user should be able to carry on working on the document while your code
runs. However you do share the same clipboard and if both code and user try
to use it at the same time there may well be conflicts - you can keep short
term exclusive use of it (and everything else) in code but the users could
do a copy, and then find themselves pasting something else which they
probably wouldn't like. You might be able to address this in Word 2000 but
not, AFAIK, in later versions - at least not in VBA code although I suppose
it must be possible via Windows.
 
R

Rama

Hi Tony,
Thanks for your reply. More than multithreading my concern is
about clip board. is there any way I can avoid using clipboard functionality
to avoid interference with user?


--
Cheers,
Rama


Tony Jollans said:
I'm not entirely sure I follow what you want, but if you include "DoEvents"
regularly in your code it should effectively simulate multithreading and the
user should be able to carry on working on the document while your code
runs. However you do share the same clipboard and if both code and user try
to use it at the same time there may well be conflicts - you can keep short
term exclusive use of it (and everything else) in code but the users could
do a copy, and then find themselves pasting something else which they
probably wouldn't like. You might be able to address this in Word 2000 but
not, AFAIK, in later versions - at least not in VBA code although I suppose
it must be possible via Windows.
 
T

Tony Jollans

Not without some very fancy low-level code, which I couldn't provide.

There is one Windows clipboard shared by all processes on the computer - if
you change it, you must restore it. The Office clipboard is actually harder
to deal with - I think you would have to intercept copy operations to stop
it being updated when appropriate. Do you really need to use the clipboard
in your code - or could you manage some other way?

--
Enjoy,
Tony

Rama said:
Hi Tony,
Thanks for your reply. More than multithreading my concern is
about clip board. is there any way I can avoid using clipboard functionality
to avoid interference with user?
 
R

Rama

Hi Tony,
Thanks for the reply. I'm using clipboard functionality to
achieve the following tasks

1) Converting plain text information into Rich text and storing in the
Database.
2) Copying inlineshape images into filesystem.

I'm using .NET and VBA code to achieve the same. Is there anyway to get away
with clipboard?
 
T

Tony Jollans

I don't know about .NET and it may have its own capacity for this.

1. There must be another way. Google seems to return lots of hits - on of
them must be good. When you say plain text do you really mean that or are
you picking up formatted text from a document?

2. If you have a recent version of Word ...

Sub SaveImage()

Dim ImageStream As ADODB.Stream


Set ImageStream = CreateObject("ADODB.Stream")
With ImageStream
.Type = 1 ' adTypeBinary
.Open
.Write ActiveDocument.InlineShapes(1).Range.EnhMetaFileBits
.SaveToFile "C:\Image.bmp"
.Close
End With

Set ImageStream = Nothing


End Sub

(needs a reference to ADO library 2.5 or higher)
 
C

Cindy M.

Hi =?Utf-8?B?UmFtYQ==?=,
1) Converting plain text information into Rich text and storing in the
Database.
Create a new document (can be "not visible"). Use the Range.Formatted
text property to transfer the "plain text" into it. Use the SaveAs method
to save this document in the RichText file format. Close it (which should
release it from memory). Now you can "stream" the RTF file.

Note: If Office 2003 is being used to create these files, and the user
can save in XML format, you wouldn't have to run Word server-side at all.
Just parse the XML.

If you can't ensure that, you can still access the document content as
XML when using automation, and parse that if you prefer.

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top