Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Prevent to create new document or oped document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bzamfir@gmail.com - 05 Sep 2006 01:43 GMT
Hi,

I have an application written in VFP (but this doesn't really mattter,
it could be in VBA too) which nmeeds to allow users to create some DOC
templates for mailmerge.

Specifically, from my app I create a word instance, create a new
document (which will be the mail merge template) and link to the CSV
data source so users can write the letter template and select fields.

To be able to control word, I implement in my app Word's Application2
interface, so I can detect when users close the document (or word) to
save it and close Word too. I use for this event
ApplicationEvents2_DocumentBeforeClose

Also, since I control the template name from external application, I
managed to prevent users to save template with different name, using
event ApplicationEvents2_DocumentBeforeSave, where if SaveAsUI is true,
I set it to false.

I want also to not let users to create or open other documents from
that instance of Word.
Unfortunately I cannot find a way to prevent this. Neither _New nor
_Open events does not have Cancel parameter, and my event handler is
called after default handler.

Also, I saw the events for Document object also does not have Cancel
parameter.

Any suggestion will be appreciated.

Thank you
Bogdan Zamfir
Jezebel - 05 Sep 2006 01:58 GMT
Ultimately you can't prevent them. But you can go a long way by trapping the
commands themselves: FileNew, FileOpen, etc.

> Hi,
>
[quoted text clipped - 29 lines]
> Thank you
> Bogdan Zamfir
Bogdan Zamfir - 05 Sep 2006 09:53 GMT
Hi,

> Ultimately you can't prevent them. But you can go a long way by trapping the
> commands themselves: FileNew, FileOpen, etc.

Thank you for your answer.
Dio you have any idea how to trap FileOpen, FileNew?
I search on google but could not find something.

Regards,
Bogdan

> > Hi,
> >
[quoted text clipped - 29 lines]
> > Thank you
> > Bogdan Zamfir
Jezebel - 05 Sep 2006 09:57 GMT
You write macros with those names.

> Hi,
>
[quoted text clipped - 42 lines]
>> > Thank you
>> > Bogdan Zamfir
Bogdan Zamfir - 05 Sep 2006 23:15 GMT
Hi,

> > Dio you have any idea how to trap FileOpen, FileNew?
> > I search on google but could not find something.

> You write macros with those names.

Unfortunately I cannot do that, because I cannot create my DOC based on
some template (so to have macros in it), but I automate Word from an
external application.

Is there any way to create macros programatically in a Word DOC from an
by automating Word?

Or those FileOpen, FileNew, are they methods (events, etc) of some
chile object of word.application object. Do you know such object ?

If so, I can "bind" those events / methods to custom methods in my code
so I can trap them this way.

Regards,
Bogdan

> > Hi,
> >
[quoted text clipped - 40 lines]
> >> > Thank you
> >> > Bogdan Zamfir
Jezebel - 06 Sep 2006 00:31 GMT
> Is there any way to create macros programatically in a Word DOC from an
> by automating Word?

This is technically possible (using the methods of the VBE object) but in
practice hard to do and usually blocked by the security settings.

> Or those FileOpen, FileNew, are they methods (events, etc) of some
> chile object of word.application object. Do you know such object ?

No, it doesn't work that way.

Since you have to install your application on the target computer, why can't
you  at the same time install an add-in that contains the necessary code?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.