"CustomDocumentProperties"-problem

  • Thread starter Rigoletto Eikenberg
  • Start date
R

Rigoletto Eikenberg

Hello,

i want to save .dot-Attachments from outlook 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.

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.

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
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Rigoletto,

I find Document Variables more convenient to work with than Document
Properties. With them you could use

wrd.ActiveDocument.Variables("BI_NAME").Value = "Rigoletto Eikenberg"

in place of

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

are you sure however that wrd.ActiveDocument is a reference to the document
that you are opening with

wrd.Documents.Open (strFile)

to be sure it might be best to

Dim wrdDoc as Object

then

Set wrdDoc = wdr.Documents.Open(strFile)

then use

wrdDoc.Variables("BI_NAME").Value = "Rigoletto Eikenberg"
wrdDoc.Close wdSaveChanges

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
R

Rigoletto Eikenberg

Hello Doug,

can a user create a variable with word or it is only accessable through VBA.
Proberties are supported, but i can´t find it for variables.
I want to prefill the doc and the user can fill it with own.

Rigoletto

"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Rigoletto,

Variables can only be loaded/accessed via vba. If you wanted the use to be
able to assign values to particular variables, you could do it by use of a
userform

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top