Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

HOW TO programatically Create A New Document in SharePoint?

  Asked By: Juan    Date: Nov 18    Category: Sharepoint    Views: 1409

Does anyone know if there is a way programatically add a document to
SharePoint (ie. html, xml or word document) ?

For example, my users want to do the following:
1. Click on a link from the SharePoint home page
2. Fill out a document profile popup form, which I have created
3. When they hit submit, it will automatically create, codify and
publish a new document in the SharePoint repository.

Is there a web part I can download that does this?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Dominic Davis     Answered On: Nov 18

You can use the Sharepoint SDK..
The samples provide you with code for creation of
documents, folders, categories etc....

this is the code that helps you create  the document.
Once created the document  is in checked out form...


Dim oDoc As PKMCDO.KnowledgeDocument
Dim oStream As ADODB.Stream
Dim nIndex As Integer
Dim sPropName As String

Set oDoc = New PKMCDO.KnowledgeDocument

Set oStream = oDoc.OpenStream
oStream.Type = adTypeBinary
oStream.SetEOS
oStream.LoadFromFile "C:\filename.doc"
oStream.Flush

If sCC <> "" Then
oDoc.ContentClass = ""
End If

oDoc.DataSource.SaveTo sHref, , ,
adCreateOverwrite

Set CreateDocument = oDoc

 
Answer #2    Answered By: Indu Raj     Answered On: Nov 18

sorry ... the code was half way through

Dim oDoc As PKMCDO.KnowledgeDocument
Dim oStream As ADODB.Stream
Dim nIndex As Integer
Dim sPropName As String

Set oDoc = New PKMCDO.KnowledgeDocument

Set oStream = oDoc.OpenStream
oStream.Type = adTypeBinary
oStream.SetEOS
oStream.LoadFromFile "C:\filename.doc"
oStream.Flush

If sCC <> "" Then
oDoc.ContentClass =
"urn:content-classes:basedocument"
End If

oDoc.DataSource.SaveTo sHref, , ,
adCreateOverwrite

Set CreateDocument = oDoc

Now the document  is uploaded and in the checked out
state

after this the document is to be checked in, the
document profile  properties set and published