vba - Why won't this loop to add CustomDocumentProperties work? -


i'm trying add few custom document properties folder of word documents.

i know loop works fine, because used same loop different code modify , update pre-existing custom document properties.

the code add custom document properties works, tested running in it's own macro single document, worked fine.

since loop works , code within loop works, can't figure out what's wrong it.

here's code:

sub add_custom_docproperties()  dim file dim path string  dim filepath variant filepath = inputbox("please enter filepath files want  update.", "input filepath", "copy filepath here...") select case strptr(response) case 0 endednotification = msgbox("the macro has been ended.", , "notification") exit sub case else end select  path = filepath & "\"  file = dir(path & "*.*")  'application.screenupdating = false  while file <> ""      documents.open filename:=path & file          check = msgbox(path & file, , "check")          activedocument.customdocumentproperties.add name:="firstdocprop",            _linktocontent:=false, type:=msopropertytypestring, value:="the first one"         activedocument.customdocumentproperties.add name:="seconddocprop",            _linktocontent:=false, type:=msopropertytypestring, value:="second"         activedocument.customdocumentproperties.add name:="thirddocprop",            _linktocontent:=false, type:=msopropertytypestring, value:="third"  'original example from: 'https://msdn.microsoft.com/en-us/vba/office-shared-vba /articles/documentproperties-add-method-office      activedocument.save     activedocument.close      'set file next in dir     file = dir()  loop  'application.screenupdating = true  msgbox "the macro complete."  end sub 

as can see have comment there first example tried msdn, modified.

thanks in advance help, if point me resource explaining i've gone wrong or that.

word not recognise changes customdocumentproperties being sufficiently important save document when execute save command - unless had made other changes decides ignore save.

you can force save telling word document has not been saved since last changed:

activedocument.saved = false activedocument.save activedocument.close 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -