Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Programatically Saving document information

  Asked By: Viral    Date: Nov 25    Category: Sharepoint    Views: 739

I am a Sharepoint newbee who has been given the task of
integrating Sharepoint with our existing software. I am having a problem
saving a document after changing any of it's properties. Here are the steps
I am taking:
1) Check out the document.
2) Check the document in.
3) Change on or more properties **ERROR (permission denied)**

I am able to perform all these steps via the dashboard so I'm fairly certain
my roles are set correctly.

Here is some sample code ( I hope this isn't too much info):

'** Open a document for editing.
Public Function GetDocument(ByVal HREF As String) As

Dim oDoc As PKMCDO.KnowledgeDocument
Dim oConn As adodb.Connection
Dim sHREF As String

On Error GoTo ErrHandler

Set oDoc = New PKMCDO.KnowledgeDocument
oDoc.PromptToAuthenticate = False

'Open the document.
Set oConn = New adodb.Connection
oConn.Open "URL=" & HREF
oDoc.DataSource.Open HREF, oConn, adModeReadWrite
Set oConn = Nothing

Set GetDocument = oDoc

Set oDoc = Nothing

Exit Function


Set oDoc = Nothing

If Not oConn Is Nothing Then
If oConn.State <> adStateClosed Then
End If
Set oConn = Nothing
End If

With Err
.Raise .Number, .Source, .Description, .HelpFile, .HelpContext
End With

End Function

'** Check a document in.
Public Sub CheckIn(ByVal PKMDocument As PKMCDO.KnowledgeDocument, _
ByVal Comments As String, _
ByVal FileName As String, _
Optional ByVal Publish As Boolean = True)

Dim oVer As PKMCDO.KnowledgeVersion
Dim oFSO As Scripting.FileSystemObject
Dim oShell As IWshRuntimeLibrary.WshShell
Dim oFolder As Scripting.Folder
Dim oStream As adodb.Stream

On Error GoTo ErrHandler

Set oFSO = New Scripting.FileSystemObject

'Copy the file to the document. (ignore this for now)
' If oFSO.FileExists(FileName) Then
' Set oStream = PKMDocument.OpenStream
' oStream.SetEOS
' oStream.Type = adTypeBinary
' oStream.LoadFromFile FileName
' oStream.Flush
' Set oStream = Nothing
' End If
' Set oFSO = Nothing

'* Test: Set a document property here.
PKMDocument.Title = "Checked In"
PKMDocument.DataSource.Save '<=== Error, "Permission Denied"

'Checkin the document.
Set oVer = New PKMCDO.KnowledgeVersion
If Len(Comments) = 0 Then
oVer.CheckIn Decode(PKMDocument.HREF)
oVer.CheckIn Decode(PKMDocument.HREF), , Comments
End If
If Publish Then
oVer.Publish Decode(PKMDocument.HREF)
End If

Set oVer = Nothing

Exit Sub


Set oFSO = Nothing
Set oShell = Nothing
Set oStream = Nothing
Set oVer = Nothing

With Err
.Raise .Number, .Source, .Description, .HelpFile, .HelpContext
End With

End Sub



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Programatically Saving document information Or get search suggestion and latest updates.