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 / Outlook / Programming Forms / December 2003

Tip: Looking for answers? Try searching our database.

"CustomDocumentProperties" Why does it not work?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rigoletto Eikenberg - 16 Dec 2003 12:05 GMT
Hello,

i want to save .dot-Attachments with customized "CustomDocumentProperties"
in the .dot-folder.
To save the .dot-File in the folder works fine, but the
"CustomDocumentProperties" are forgotten.
I can check they after adding with
   MsgBox wrd.ActiveDocument.CustomDocumentProperties("BI_NAME")
but they are not saved. I try "save" and "close" with paramenters to save
without asking for it. But it does not work too.

Can somebody help`?

Rigoletto

Office XP with SP2

Sub vorlagen_speichern_Click() ' .dot-Anlagen werden im Vorlagenverz.
gespeichert und aktuallisiert.
i = 0

Set wrd = CreateObject("Word.Application")
dotpath = wrd.Options.DefaultFilePath(2)

' wrd.Application.Visible = True

Set colAtts = Item.Attachments
If colAtts.Count > 0 Then
 For Each objAtt In colAtts
  If Right(objAtt.Filename, 4) = ".dot" then
   strFile = dotpath & "\" & objAtt.FileName
   objAtt.SaveAsFile strFile
   i = i + 1

   wrd.Documents.Open (strFile)

   On Error Resume Next
   wrd.ActiveDocument.CustomDocumentProperties("BI_NAME").Delete
   On Error Goto 0
   wrd.ActiveDocument.CustomDocumentProperties.Add "BI_NAME", 0, 4,
"Rigoletto Eikenberg"

   wrd.ActiveDocument.Save
   wrd.ActiveDocument.Close
  End If
 Next
 MsgBox i & " Word-Vorlagen in " & dotpath & " installiert."
else
 MsgBox "Es sind keine Anlagen vorhanden die als Word-Vorlage gespeichert
werden k?nnten."
End If

Set wrd = Nothing

End Sub
Sue Mosher [MVP] - 16 Dec 2003 14:10 GMT
You might want to ask in a Word newsgroup, since after you save the attachment as a file, Outlook is no longer involved at all, and this definitely seems like a Word issue.  
Signature

Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
    Microsoft Outlook Programming: Jumpstart
    for Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx 

> Hello,
>
[quoted text clipped - 51 lines]
>
> End Sub
Rigoletto Eikenberg - 16 Dec 2003 14:33 GMT
Hello Sue Mosher,

oh i see. But can it be a problem with outlook? Because i record parts of
the script in word as a marco and copy it to word. In word in runs fine,
only when i try to put it in outlook the problem occurs.

I post it in the word newsgroup, probably it is a problem with the
com-interface or such a strange thing!?

Your articles are very fine :-)

Greetings
Rigoletto

You might want to ask in a Word newsgroup, since after you save the
attachment as a file, Outlook is no longer involved at all, and this
definitely seems like a Word issue.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
    Microsoft Outlook Programming: Jumpstart
    for Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Hello,
>
[quoted text clipped - 51 lines]
>
> End Sub
Sue Mosher [MVP] - 16 Dec 2003 15:40 GMT
You mean that you're running the code in Outlook VBA? That shouldn't make any difference, since it's using the same object library as Word VBA. I think you could improve the code, though, by using an explicit reference to the document, rather than ActiveDocument. Since the document isn't displayed, maybe Word isn't treating it as active:

   Set wrd = CreateObject("Word.Application")
   strFile = "whatever yoiu named it.dot"
   Set objDoc = wrd.Documents.Open (strFile)
   With objDoc
       .CustomDocumentProperties("BI_NAME").Delete
       .CustomDocumentProperties.Add "BI_NAME", 0, 4, "Rigoletto Eikenberg"
       .Save
       .Close
   End With
Signature

Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
    Microsoft Outlook Programming: Jumpstart
    for Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

Rigoletto Eikenberg - 18 Dec 2003 13:55 GMT
Now i got it work. Thanks for your help.
When it is finished i will public it.

Rigoletto

You mean that you're running the code in Outlook VBA? That shouldn't make
any difference, since it's using the same object library as Word VBA. I
think you could improve the code, though, by using an explicit reference to
the document, rather than ActiveDocument. Since the document isn't
displayed, maybe Word isn't treating it as active:

   Set wrd = CreateObject("Word.Application")
   strFile = "whatever yoiu named it.dot"
   Set objDoc = wrd.Documents.Open (strFile)
   With objDoc
       .CustomDocumentProperties("BI_NAME").Delete
       .CustomDocumentProperties.Add "BI_NAME", 0, 4, "Rigoletto Eikenberg"
       .Save
       .Close
   End With
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
    Microsoft Outlook Programming: Jumpstart
    for Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 
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.