Bonjour Paolo

There is a solution, using getArgs() from the document. This returns an array of PropertyValue with interesting data. This array changes when the new document is saved. But until it is saved, you get a Title property containing the provisional name used for display. As an example, put this in "My Macros" and run it with different documents at foreground:

option explicit

Sub currentDocTitle
findUserTitle(ThisComponent)
End Sub

Sub findUserTitle(thisDoc as object)
dim docArgs as object
dim n as long, a as variant
docArgs = thisDoc.getArgs()
if thisDoc.hasLocation  then
  a = split(convertFromURL(thisDoc.Location), getPathSeparator())
  MsgBox(a(UBound(a)) ' file name
else
  for n = LBound(docArgs) to UBound(docArgs)
    if docArgs(n).Name = "Title"  then
      MsgBox(docArgs(n).Value) ' unnamed document
      Exit Sub
    end if
  next
  MsgBox("Not found !", 16)
end if
End Sub

Still a problem: if the document is created Hidden, the Title is always "untitled" (localized string) even if there are several hidden documents of the same type...

The type of the new document could be deducted from property FilterName in docArgs array.

Regards
  Bernard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to