O
Omega
Hi!
I am new user to COM objects, so sorry if the questions are easy, I tried
googling it, but I didn't find the answer, so I ask you:
I am writing an application. I open word document from it, sometimes the
document exists, sometimes I want to open new document in word. So far I
opened word and I handle DocumentBeforeSave event. I have still got three
problems:
1) I would like to only catch Save and SaveAs events, not AutoSave, but
from what I noticed DocumentBeforeSave catches all three of them. Can I
somehow switch off the autoSave, or tell which one of these events caused
the DocumentBeforeSave event?
2) I would like to prevent the document from saving after
DocumentBeforeSave event is handled. I tried setting Cancel to true and
SaveAsUI to false, but it does not seem to work. I read somewhere, that
"Cancel = true;" should be the last operation in handling methos, or that I
should call "return;" or "Exit Sub;" in VB to prevent document from saving.
3) While the Word application is opened, my main application is still
running. After each save in word, I would like to refresh some components
on my main frame. Now it doesn't work, I get exceptions in OnPaint event. I
know that Word is opened in new thread, can it be the reason, why
refreshing does not work? How can I make it work?
I will be gratefull for any answers, links to some useful articles etc.
Omega
I am new user to COM objects, so sorry if the questions are easy, I tried
googling it, but I didn't find the answer, so I ask you:
I am writing an application. I open word document from it, sometimes the
document exists, sometimes I want to open new document in word. So far I
opened word and I handle DocumentBeforeSave event. I have still got three
problems:
1) I would like to only catch Save and SaveAs events, not AutoSave, but
from what I noticed DocumentBeforeSave catches all three of them. Can I
somehow switch off the autoSave, or tell which one of these events caused
the DocumentBeforeSave event?
2) I would like to prevent the document from saving after
DocumentBeforeSave event is handled. I tried setting Cancel to true and
SaveAsUI to false, but it does not seem to work. I read somewhere, that
"Cancel = true;" should be the last operation in handling methos, or that I
should call "return;" or "Exit Sub;" in VB to prevent document from saving.
3) While the Word application is opened, my main application is still
running. After each save in word, I would like to refresh some components
on my main frame. Now it doesn't work, I get exceptions in OnPaint event. I
know that Word is opened in new thread, can it be the reason, why
refreshing does not work? How can I make it work?
I will be gratefull for any answers, links to some useful articles etc.
Omega