Editing document outside of word - cannot open

T

TimmyG

Hello all,

I am experimenting with word documents in a web application
environment. In order to avoid any degree of server side automation we
came up with the possibility of altering the document content wihtout
going anywhere need the word application itself. I.E. opening the
document programatically as some type of stream, finding and replacing
various text and writing the doc to file system etc.

My problem is this:

When editing a word document via notepad or via code the document
cannot then be re-opened with word, the following message appears: The
document name or path is not valid: Try the following...blah blah
blah.

Have tried all i can find in terms of openeing but still fails.

Am i corrupting the document in someway?

If done with RTF files there is no problem at all, i do however need
macro functionality so RTF is not really viable.

Much obliged,
TimmyG.
 
M

Margaret Aldis

Hi TimmyG

I think you are on a hiding to nowhere here. Word doesn't store documents as
a 'stream' - any change you make in the text when you edit in Word is also
reflected in some arcane (and not publicly available) tables and pointers
also stored in the file. So yes, you are corrupting the file by attempting
to edit the text.

I don't really understand what you are trying to do here, but if RTF works,
can you solve this by keeping all your macros in the attached template,
rather than in the document itself? That way they should still be available
to the document once reopened in Word?
 
M

martinique

Yes, almost certainly you are corrupting the document. A document file is a
very complicated beast. The structure is not publicly documented, and is in
some unspecified respects polymorphic (ie open a document, make a change,
undo the change, save -- the new document may have a different *structure*
to the old). It contains both a text and a data fork: the data fork
containing macro code, settings, variables, etc; the text fork containing up
to seven separate story ranges (body, headers, footers, textboxes, comments,
etc), six of which are handled as linked lists. The text itself may be a
mixture of ASCII and Unicode. And there may be information about change
history and prior versions.

Hiding to nothing is right.
 
T

TimmyG

Yeah, cheers guys, had come to that conclusion anyway, was a long shot
in the dark to solve a specefic problem.

RTF will work fine but it is likely i will need some type of macro
functionality at the client.

Obliged and out,
TimmyG.
 
T

TimmyG

Sorry Maragaret, didn't see your last comment regarding attaching a
template. This sounds promising. Could you explain a little more in
terms of attaching a template with regard to a web architecture? What
i am getting at is that these documents will be downloaded from a web
server, worked on on the client machine and then uploaded when
complete. If I attach a template via a path on the server will this
template make it's way to the client machine and will it's
functionality still be available?

Obliged,
TimmyG.
 
M

Margaret Aldis

Hi TimmyG

Ah - I didn't realise these were macros to be used on the downloaded
document. I thought this was about automatic editing *not* using Word,
without losing Word readability when the document was reopened in its
original location.

Word will look for the template attached to a document using the full stored
path if necessary (if it can't find a template of that name in the user
templates or workgroup templates directory) so if you are on a local network
the template can be found on another server. But if you mean will Word pull
macros from a template on a Web server to run on a client machine I don't
believe that will work (in fact, I have a feeling that it used to work but
was a security hole that has been plugged).

Sorry, don't think I'm going to be much use to you here. Maybe if you
explain the full requirement someone here or in one of the VBA groups may
have met the problem before.
 

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