Discussion:
An AfterCloseEvent
(too old to reply)
Perry
2007-01-17 18:30:24 UTC
Permalink
Following VBA statement:

Debug.Print oDoc.Name

prints out the name of a document beautifully, assuming oDoc as a valid
object
pointing to a newly created document.
Assuming oDoc was instantiated using similcar code like:
Set oDoc = Documents.Add("MyTemplate.dot")

If this doesn't work, you'll have to kick in more info ...
Krgrds,
Perry
Hello,
I have the following problem: I am currently writing an Add-In, which
writes
into a file, if a document was newly created.
If a user creates a new document and does not save the document before he
closes word, then I cant get the filename via the BeforeCloseEvent,
because
it is raised before saving the document. How can I get the filename of a
newly created document?
Thx for any hint!
Jens
Jens Sauer
2007-01-21 17:12:00 UTC
Permalink
Hello,

in my case this solution is not useful, because my add-in do not instantiat
the document. I just use the BeforeCloseEvent and want to log, which document
was opened.
Post by Perry
Debug.Print oDoc.Name
prints out the name of a document beautifully, assuming oDoc as a valid
object
pointing to a newly created document.
Set oDoc = Documents.Add("MyTemplate.dot")
If this doesn't work, you'll have to kick in more info ...
Krgrds,
Perry
Hello,
I have the following problem: I am currently writing an Add-In, which
writes
into a file, if a document was newly created.
If a user creates a new document and does not save the document before he
closes word, then I cant get the filename via the BeforeCloseEvent,
because
it is raised before saving the document. How can I get the filename of a
newly created document?
Thx for any hint!
Jens
Perry
2007-01-21 22:11:36 UTC
Permalink
Then you have to raise the eventhandler up to the application level.
Insert a class module and clip in below statements.

For more info on Application event handling look here:
http://msdn2.microsoft.com/en-us/library/aa211915(office.11).aspx

'Classmodule code
Public WithEvents wd As Word.Application

Private Sub wd_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
End Sub

Krgrds,
Perry
Hello,
in my case this solution is not useful, because my add-in do not instantiat
the document. I just use the BeforeCloseEvent and want to log, which document
was opened.
Post by Perry
Debug.Print oDoc.Name
prints out the name of a document beautifully, assuming oDoc as a valid
object
pointing to a newly created document.
Set oDoc = Documents.Add("MyTemplate.dot")
If this doesn't work, you'll have to kick in more info ...
Krgrds,
Perry
Hello,
I have the following problem: I am currently writing an Add-In, which
writes
into a file, if a document was newly created.
If a user creates a new document and does not save the document before he
closes word, then I cant get the filename via the BeforeCloseEvent,
because
it is raised before saving the document. How can I get the filename of a
newly created document?
Thx for any hint!
Jens
Loading...