Word 2007 Custom Document Properties, VBA and Sharepoint 2007

P

pm620wh

Hi

I've created a document library in Sharepoint 2007 and added some custom
fields to capture metadata from Word 2007 documents when they are uploaded.

If I upoad a document manually to the SharePoint library, everything works
as expected and the custom document properties stored inside my Word document
synchronise to the fields in my sharepoint list. However, if I try to save
the Word document to my libary using VBA code i.e. "Document.SaveAs" (using
the URL that points to the SharePoint library as the document path), the
document saves to the library, but none of the custom document properties
transfer and the fields in my list are empty

I've tried making some of the fields mandatory to see what would happen and
as a result, when I save the document using VBA code, a dialogue box appears
telling me that I have to provide the missing data (even though the custom
document properties of the document are fully populated).
 
T

Tim Li - MSFT

Hello Paul,

Unfortunately, I could not reproduce this issue in my side, I tried to
reproduce this issue by following code :

ActiveDocument.SaveAs
"http://myasia/sites/v-timli/Personal Documents/b.docx",
FileFormat:=Word.WdSaveFormat.wdFormatDocumentDefault

I have the same environment as yours, Word 2007 and SharePoint Server
2007.As I know SharePoint will not discard any information within the
upload document, the issue should stays in Word side. Do you have any
different parameter than I have?

Also I've found a similar thread which discussed a scenario when changing
the Custom Properties in a Word Document. Please refer to this link:

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=micros
oft.public.word.vba.addins&tid=4261fa3b-1e5c-46e1-a4eb-dce5b28045a2&cat=&lan
g=&cr=&sloc=&p=1

As you mentioned, you could successfully save the properties manually in
Word UI, therefore, we could record a macro and then check the code
generated by Word automatically.

Best regards,
Tim Li
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
P

pm620wh

Hi Tim

Thanks for trying. I'm wondering if I'm missing a step somewhere (but not
sure how). When I say "I uploaded the document manually" I use the Sharepoint
interface for uploading a document and this works ok.

If I try to save the document to the sharepoint server from the word UI, or
try to use VBA code, all the custom document properties are ignored.

I was wondering, would you like to take a copy of my document and save it to
the library yourself. Perhaps you can see something that I have missed out?

Kind regards

Paul
 
T

Tim Li - MSFT

Sure, please send the document to (e-mail address removed) remove
online. Would you please also include the VBA code in document?It will help
me to fully understand what's going on there.

Best regards,
Tim Li
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
P

pm620wh

Hi Tim

Here's a strange one. I was tinkering today before sending you the document
and got the attributes to synchronise. I disabled the "On Error Resume Next
statement" (which is immediately before my Activedocument.SaveAs command).
As soon as I uncomment the the "On Error" statement, the problem comes back.
So the code looks like this:

On Error Resume Next
ActiveDocument.SaveAs "http://pma-msweb.pmaconsulting.net/MSEA Pipeline/"
& ActiveDocument.Name, FileFormat:=Word.WdSaveFormat.wdFormatDocumentDefault,
AddToRecentFiles:=False

Would you like to try this out and see if you get the same results.
 
P

pm620wh

Hi Tim

Strike that previous post - I have not successfully managed to recreate the
conditions under which the document properties will not sync properly. To
set this up, ensure your documents "Close event" has some code that will save
the document to the SharePoint server each time you close the file e.g.

On Error Resume Next
ActiveDocument.SaveAs "http://pma-msweb.pmaconsulting.net/MSEA Pipeline/"
& ActiveDocument.Name, FileFormat:=Word.WdSaveFormat.wdFormatDocumentDefault,
AddToRecentFiles:=False

Now, do the following:

1. Created and edit your document so it has new custom document properties
2. Click File->Close to close the document
3. Word will prompt you for the credentials to the Sharepoint server
4. The document will save and the properties will synchronise

Note: Word has not unloaded from memory at this time

5. Now reopen the document and make some changes to the doc
6. Click File->Close
7. Word SHOULD NOT ask your for your credentials again
8. The document has saved to the server, but the document properties are now
ALL EMPTY

Close Microsoft Word altogether (unload from memory).

9. Launch Word and re-open the document
10. Click File->Close, Word will ask you for your credentials to the
Sharepoint server
11. The document will save and the properties will sync!!

I can make this happen over and over again. Can you?

Kind regards

Paul
 
R

Richard Ã…strand

Hello.

I found your thread and are experiencing similar problems with syncing property values between Word documents using teh DIP and SharePoint library.

Editing the properties using the DIP saves all values within the document, but when the document is saved into SharePoint, none of the values are transfered.
Editing the properties inside SharePoint updates the values in SharePoint, but these values are not transfered into the document, aka not visible in the DIP when opening the document for edit in Word.

There are no custom code involved here. No VBA code or custom SharePoint features. Everything is set up using out of the box features.

Any help or insight would be much appreciated.
Thanks.



pm620wh wrote:

Word 2007 Custom Document Properties, VBA and Sharepoint 2007
20-Aug-09

H

I have created a document library in Sharepoint 2007 and added some custo
fields to capture metadata from Word 2007 documents when they are uploaded

If I upoad a document manually to the SharePoint library, everything work
as expected and the custom document properties stored inside my Word documen
synchronise to the fields in my sharepoint list. However, if I try to sav
the Word document to my libary using VBA code i.e. "Document.SaveAs" (usin
the URL that points to the SharePoint library as the document path), th
document saves to the library, but none of the custom document propertie
transfer and the fields in my list are empt

I have tried making some of the fields mandatory to see what would happen an
as a result, when I save the document using VBA code, a dialogue box appear
telling me that I have to provide the missing data (even though the custo
document properties of the document are fully populated)
--
Paul

Previous Posts In This Thread:

Word 2007 Custom Document Properties, VBA and Sharepoint 2007
H

I have created a document library in Sharepoint 2007 and added some custo
fields to capture metadata from Word 2007 documents when they are uploaded

If I upoad a document manually to the SharePoint library, everything work
as expected and the custom document properties stored inside my Word documen
synchronise to the fields in my sharepoint list. However, if I try to sav
the Word document to my libary using VBA code i.e. "Document.SaveAs" (usin
the URL that points to the SharePoint library as the document path), th
document saves to the library, but none of the custom document propertie
transfer and the fields in my list are empt

I have tried making some of the fields mandatory to see what would happen an
as a result, when I save the document using VBA code, a dialogue box appear
telling me that I have to provide the missing data (even though the custo
document properties of the document are fully populated)
--
Paul

Hello Paul,Unfortunately, I could not reproduce this issue in my side, I tried
Hello Paul

Unfortunately, I could not reproduce this issue in my side, I tried t
reproduce this issue by following code

ActiveDocument.SaveA
"http://myasia/sites/v-timli/Personal Documents/b.docx"
FileFormat:=Word.WdSaveFormat.wdFormatDocumentDefaul

I have the same environment as yours, Word 2007 and SharePoint Serve
2007.As I know SharePoint will not discard any information within th
upload document, the issue should stays in Word side. Do you have an
different parameter than I have

Also I have found a similar thread which discussed a scenario when changin
the Custom Properties in a Word Document. Please refer to this link

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=micro
oft.public.word.vba.addins&tid=4261fa3b-1e5c-46e1-a4eb-dce5b28045a2&cat=&la
g=&cr=&sloc=&p=

As you mentioned, you could successfully save the properties manually i
Word UI, therefore, we could record a macro and then check the cod
generated by Word automatically

Best regards
Tim L
Microsoft Online Community Suppor

Delighting our customers is our #1 priority. We welcome your comments an
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

Hi TimThanks for trying.
Hi Tim

Thanks for trying. I am wondering if I am missing a step somewhere (but not
sure how). When I say "I uploaded the document manually" I use the Sharepoint
interface for uploading a document and this works ok.

If I try to save the document to the sharepoint server from the word UI, or
try to use VBA code, all the custom document properties are ignored.

I was wondering, would you like to take a copy of my document and save it to
the library yourself. Perhaps you can see something that I have missed out?

Kind regards

Paul
--
Paul


:

RE: Word 2007 Custom Document Properties, VBA and Sharepoint 2007
Sure, please send the document to (e-mail address removed) remove
online. Would you please also include the VBA code in document?It will help
me to fully understand what is going on there.

Best regards,
Tim Li
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

Hi TimHere's a strange one.
Hi Tim

Here is a strange one. I was tinkering today before sending you the document
and got the attributes to synchronise. I disabled the "On Error Resume Next
statement" (which is immediately before my Activedocument.SaveAs command).
As soon as I uncomment the the "On Error" statement, the problem comes back.
So the code looks like this:

On Error Resume Next
ActiveDocument.SaveAs "http://pma-msweb.pmaconsulting.net/MSEA Pipeline/"
& ActiveDocument.Name, FileFormat:=Word.WdSaveFormat.wdFormatDocumentDefault,
AddToRecentFiles:=False

Would you like to try this out and see if you get the same results.

--
Paul


:

Hi TimStrike that previous post - I have not successfully managed to recreate
Hi Tim

Strike that previous post - I have not successfully managed to recreate the
conditions under which the document properties will not sync properly. To
set this up, ensure your documents "Close event" has some code that will save
the document to the SharePoint server each time you close the file e.g.

On Error Resume Next
ActiveDocument.SaveAs "http://pma-msweb.pmaconsulting.net/MSEA Pipeline/"
& ActiveDocument.Name, FileFormat:=Word.WdSaveFormat.wdFormatDocumentDefault,
AddToRecentFiles:=False

Now, do the following:

1. Created and edit your document so it has new custom document properties
2. Click File->Close to close the document
3. Word will prompt you for the credentials to the Sharepoint server
4. The document will save and the properties will synchronise

Note: Word has not unloaded from memory at this time

5. Now reopen the document and make some changes to the doc
6. Click File->Close
7. Word SHOULD NOT ask your for your credentials again
8. The document has saved to the server, but the document properties are now
ALL EMPTY

Close Microsoft Word altogether (unload from memory).

9. Launch Word and re-open the document
10. Click File->Close, Word will ask you for your credentials to the
Sharepoint server
11. The document will save and the properties will sync!!

I can make this happen over and over again. Can you?

Kind regards

Paul


Submitted via EggHeadCafe - Software Developer Portal of Choice
NoSQL, MongoDB Install, Lotus Notes, and CouchDB
http://www.eggheadcafe.com/tutorial...-mongodb-install-lotus-notes-and-couchdb.aspx
 

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

Top