Determine the Sharepoint Library

M

Mo

Hi,
When creating a new Word document from a library in Sharepoint and then
saving it from Word, it suggests to save it in that same library I created
the document from. I would like to know how Word "knows" which library to
suggest? Can I find that information programatically?

What I want to achieve is that the created document programatically creates
another new document and saves it to the same library as the original
document was created from. And I don't intend to save the first created
document. I know how to do this except to find the path to the library.

Any help is highly appreciated,

Peeter
 
D

Doug Robbins - Word MVP

How is the document actually being created? From a template or by opening a
document? Have you tried using the .FullName attribute of the attached
template or of the file?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
M

Mo

Hi and thanks,

The document is, and could be, created from any document library in SP2010.
There is a content type that has a .dotm as the template for that content
type.

When you create a new document from within SP2010, it opens up in Word as
"Document 1" and it doesn't yet have any name, so any .path or .fullname
doesn't work.

I have browsed through the xml of the document, both internally via
..WordOpenXML property and externally by examining the .zip structure, but
haven't found any references ther to the document library the document is
created from.

Somehow there is a connection, because when you save the document, Word
proposes the correct document library. It seems like there is an event
handler in SP2010 that has a handle to to the document. Is there any way to
"take over" that handle to the newly created document?

In Word, if you save the first created document, the one that I don't want,
and then save the second document - the one created via code in the first
document, Word remembers the last save and suggests the same document
library. But I don't want to save the first document, so that is not an
option.

TIA,
Peeter
 
D

Doug Robbins - Word MVP

Does the document have a template attached to it, other than the Normal
Template?

What is displayed if you run a macro containing the following code on such a
document?

Set myTemplate = ActiveDocument.AttachedTemplate
MsgBox myTemplate.Path & Application.PathSeparator _
& myTemplate.Name


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
D

Doug Robbins - Word MVP

I guess that is not the path that you are wanting to obtain?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
M

Mo

No :)

But it seems that in every document library you add contentTypes with an
attached template, the templates end up in a subdirectory that starts with
"/Forms" etc to that document library. So, for now I'm on that track.

Next thing I want to solve :)

When the user saves a document to a document library, that is not created
from within SP2010, she is asked to apply one of the possible contentTypes
from a list.

As we in our situation know which contentType we want the user to pick, we
want to remove that step for the user.

Is there a way, via the Word object model, to set the desired contentType? I
have not found any explicit property for that.

Via ActiveDocument.ContentTypeProperties.SchemaXml you can get information
but it is a read-only property.

Is it possible and what is required to manipulate the entire xml which can
be reached via ActiveDocument.WordOpenXML?

Or is there another way?

Thanks,
Peeter
 
D

Doug Robbins - Word MVP

Sorry, I do not know anything about Sharepoint, so I have cross posted this
to several of the Sharepoint newsgroups where it may be seen by someone who
can help you further.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
M

Mo

OK, thanks anyway!
/P

Doug Robbins - Word MVP said:
Sorry, I do not know anything about Sharepoint, so I have cross posted this
to several of the Sharepoint newsgroups where it may be seen by someone who
can help you further.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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