Saving Word files NOT to the file system

C

Chuck Hartman

I would like to create a Word Templage Project that (for security reasons)
saves files either to isolated storage or (even better) to a string object.
Is it possible to save Word files somewhere other than the "normal" file
system? If so, how? Thanks.

Chuck Hartman
 
P

Peter Huang [MSFT]

Hi

Based on my experience, so far the windows OS is still using the FileSystem
as the persistent storage.

So for your scenario, I think the problem is how to secure the file you
have saved.
1. We can utilize the NT system, we can save the file to a folder which
only the dedicated person can access to it.
2. We can encrypt the file after saved and decrypt it before encoding.

For Cryptography issue you may try to refer to the MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/s
ecurity/cryptography_portal.asp

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cindy M -WordMVP-

Hi Chuck,
I would like to create a Word Templage Project that (for security reasons)
saves files either to isolated storage or (even better) to a string object.
Picking up on your second thought: if you're targeting Word 2003 you could,
possibly, extract the entire content of the document as XML (in string form)
and save that somewhere (like in a database). Place procedures in the
template named FileSave and FileSaveAs to intercept Word's built-in commands
of those names, and make sure AutoBackup is disabled.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
C

Chuck Hartman

Thanks Cindy,

I am able to do part of what I need to do with this technique, but as
always, getting by one roadblock seems to uncover another.

I am already handling the New, Open and Close events in my C#
OfficeCodeBehind class. When you say to intercept Word's built-in FileSave
and FileSaveAs commands, are you suggesting that I handle the
Microsoft.Office.Interop.Word.ApplicationClass.ApplicationEvents2_Event_DocumentBeforeSave
event? Is it possible to intercept any arbitrary built-in command or just
those events that are currently defined in the Microsoft.Office.Interop.Word
namespace?

Also, what would be the easiest way to pass a .Net object from one
document's instance of my OfficeCodeBehind to another? They are both
documents in the same application object. I thought a static variable in my
OfficeCodeBehind class would work, but it did not.

Thanks.

Chuck Hartman
 
P

Peter Huang [MSFT]

Hi,

1.Yes, we can only handle the know event provided by Word object modal.
2. I think we may have to exchange data via the File, because so far it is
hard to get the instance of one codebehindclass from another.
..NET provide powerful serialization function to help us dump object to the
file and load them back again.
Here is an article you may have a look.
Object Serialization in the .NET Framework
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/objserializ.asp

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cindy M -WordMVP-

Hi Chuck,
When you say to intercept Word's built-in FileSave
and FileSaveAs commands, are you suggesting that I handle the
Microsoft.Office.Interop.Word.ApplicationClass.ApplicationEvents2_Event_Docum
entBeforeSave
event? Is it possible to intercept any arbitrary built-in command or just
those events that are currently defined in the Microsoft.Office.Interop.Word
namespace?
From the .NET interface you can only intercept the events.

IF you are allowed to put code in the document's or template's VBA project,
then you can intercept the builtin commands. When you used the term "template
project" in your original message, I assumed you meant the VBA project. Peter
apparently knew better <g>, and assumed y .NET (VSTO?) project.

If a Word VBA project contains a procedure with the same name as a built-in
command, that procedure will intercept the built-in command. This capability
comes from the old WordBasic days; we Word-programmers were happy to see it
survive the transition to VBA, but it's been progressively neglected with
each new version since 97. So I fear it may eventually be phased out...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
C

Chuck Hartman

Cindy,

Thanks for your insights. I have created a couple of VBA Word project in the
past, but they were mostly scripting some repetitive tasks. My new project
is trying to use Word as part of a very distributed, tightly integrated
solution that includes Win Forms, ASP.NET, and XML Webservices. I'm finding
that I am beating my head against the wall quite a bit trying to integrate
Word 2003 into the various pieces of the solution. Most of the issues stem
from the restrictions due to having to use Interop assemblies themselves,
not due to the Word Object model itself.

If Microsoft is listening, here are a few future features that would enhance
the development experience:

- A Word command to "SaveCopyAs", which would leave the current document
as-is, but save a copy of the document in a given format to a specific
place. Transforming the XML document with XSL almost works, but due to
"internal Word state issues" this approach is much more complicated that it
should be.
- It would be nice to be able to save Office files to streams in .Net
Isolated Storage.
- It would be nice to be able to enable or disable ANY Word command and also
to be able to intercept ANY Word command from the OfficeCodeBehind class.
- I hope the future direction is to eliminate the COM Interop assemblies and
give us native .Net assemblies for the Office components. If so, I think it
would be very convenient to be able to derive user .Net classes from the
Application and Document objects so other useful state information (e.g.
server credentials, etc.) could be used by the event handlers.

Thanks.

Chuck Hartman
 
P

Peter Huang [MSFT]

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