Click here to Skip to main content
15,916,432 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: OnPaint method Pin
Christian Graus21-Feb-05 17:08
protectorChristian Graus21-Feb-05 17:08 
GeneralRe: OnPaint method Pin
Dave Kreskowiak22-Feb-05 0:22
mveDave Kreskowiak22-Feb-05 0:22 
GeneralRe: OnPaint method Pin
cadorna200322-Feb-05 0:45
cadorna200322-Feb-05 0:45 
GeneralIBindStatusCallback Pin
Jack Clift21-Feb-05 14:32
Jack Clift21-Feb-05 14:32 
GeneralWin32 Hooks Pin
jcrussell21-Feb-05 14:20
jcrussell21-Feb-05 14:20 
GeneralRe: Win32 Hooks Pin
Dave Kreskowiak21-Feb-05 15:30
mveDave Kreskowiak21-Feb-05 15:30 
GeneralRe: Win32 Hooks Pin
jcrussell21-Feb-05 17:04
jcrussell21-Feb-05 17:04 
GeneralRe: Win32 Hooks Pin
rwestgraham21-Feb-05 22:53
rwestgraham21-Feb-05 22:53 
This is not impossible by any means, at least not up through Word 2002 anyway. I know nothing about Word 2003 but I would assume it still supports Automation.

I have written something similar to what you describe - basically a document management type of application. We had documents that were stored on a remote server, users opened documents from a web page, and edited them using their local Word instance. Then we needed to trap the user save events in order to preserve the document names as well as launch an FTP transfer to automatically send the modified document back to the remote server.

Basically what you have to do is get the active instance of Word, and then sink the events in your application.

Word fires a DocumentBeforeSave event when the user attempts to save the document. If you set the SaveAsUI property to false in this event, it will suppress the Word Save Dialog. Then you add your custom code to control how the document is saved.

That part is simple enough.

There are some caveats:

1) If you always launch Word from your document control application, then you always have the reference and can sink events. But depending on your system, you may have to account for the possibility of a user launching Word itself then editing a controlled document. So your application may need to run all the time, and poll the system frequently to see if Word has been launched externally.

2) Again depending on your system, it may be possible for people to circumvent your controlled environment by copying/and or renaming controlled documents outside of Word - i.e using Windows Explorer. Obviously if you need to save a doc, users will have read/write access. So you cannot easily enforce this by file system permissions.

You can trap this by using another feature of Word Automation object model. Documents provide a generic Variables collection. You can create your own variables that you can control by your code. For example, suppose you need to prevent a user from copying a document from Windows Explorer into a new file name and then editing it in Word. Embed the document name in a custom Document.Variable. When the user opens a document, you compare the file name to the embedded name, and if they don't match, act as you deem fit - i.e forcibly rename the document, close it as "corrupt", whatever.

3) This is MOST important: People use Word for a variety of reasons, and it is almost certain that only some documents will actually fall within the scope of your document control system. (A private memo to Personnel, for example, is after all private and not only do you probably not want such docs to find their way into your managed document group, it could potentially result in a lawsuit. Plus in this mercernarial world we live in, should people really be prevented from polishing up their resume on their lunch hour? LOL!! I don't think so... Smile | :)

With an ubiquitous application like Word, you definitely need a way to determine if any given document is not part of your managed collection. In which case, your custom code should not run, but rather should allow the standard Word functionality to be re-established.

You accomplish this also by use of embedded variables. You sink the events for all documents, but you should check for the presence or absence of some custom embedded variable in the document to differentiate between a managed document versus an unmanged document, and run or abort your custom actions accordingly.

4) etc etc..

To make a long story short, tapping into the Word interfaces and implementing a custom save action is not the difficult task.

Making sure that your system reliably manages documents which require management, and not only ignores but also does not interfere at all with documents that are not part of a managed group is the real chore.

Designing an effective system will require some thought, and quite a bit of testing as well. Users can be very unpredictable... Big Grin | :-D

Hope this helps,

Robert



GeneralRe: Win32 Hooks Pin
Dave Kreskowiak22-Feb-05 3:36
mveDave Kreskowiak22-Feb-05 3:36 
GeneralRe: Win32 Hooks Pin
jcrussell22-Feb-05 16:30
jcrussell22-Feb-05 16:30 
GeneralRe: Win32 Hooks Pin
rwestgraham22-Feb-05 19:13
rwestgraham22-Feb-05 19:13 
QuestionHow i can create myself component with vb.net? Pin
MGunes21-Feb-05 12:21
MGunes21-Feb-05 12:21 
AnswerRe: How i can create myself component with vb.net? Pin
Christian Graus21-Feb-05 13:00
protectorChristian Graus21-Feb-05 13:00 
GeneralRe: How i can create myself component with vb.net? Pin
MGunes21-Feb-05 23:39
MGunes21-Feb-05 23:39 
GeneralRe: How i can create myself component with vb.net? Pin
MGunes21-Feb-05 23:39
MGunes21-Feb-05 23:39 
GeneralRe: How i can create myself component with vb.net? Pin
Christian Graus22-Feb-05 8:38
protectorChristian Graus22-Feb-05 8:38 
QuestionChange order in Registry? Pin
endurekona21-Feb-05 10:03
endurekona21-Feb-05 10:03 
AnswerRe: Change order in Registry? Pin
Dave Kreskowiak21-Feb-05 12:18
mveDave Kreskowiak21-Feb-05 12:18 
Generalan easy way to change the initial view state of the listview in the Open/SaveFileDialog. Pin
DavidMLevine21-Feb-05 7:18
DavidMLevine21-Feb-05 7:18 
GeneralRe: an easy way to change the initial view state of the listview in the Open/SaveFileDialog. Pin
Dave Kreskowiak21-Feb-05 15:29
mveDave Kreskowiak21-Feb-05 15:29 
GeneralRe: an easy way to change the initial view state of the listview in the Open/SaveFileDialog. Pin
DavidMLevine21-Feb-05 17:46
DavidMLevine21-Feb-05 17:46 
GeneralRe: an easy way to change the initial view state of the listview in the Open/SaveFileDialog. Pin
rwestgraham21-Feb-05 20:48
rwestgraham21-Feb-05 20:48 
GeneralRe: an easy way to change the initial view state of the listview in the Open/SaveFileDialog. Pin
DavidMLevine22-Feb-05 16:30
DavidMLevine22-Feb-05 16:30 
GeneralAdd suffix to a VB Variable Name Pin
Computer_Guy21-Feb-05 7:03
Computer_Guy21-Feb-05 7:03 
GeneralRe: Add suffix to a VB Variable Name Pin
Dave Kreskowiak21-Feb-05 8:22
mveDave Kreskowiak21-Feb-05 8:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.