Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Code Needed

  Asked By: Margarita    Date: Mar 03    Category: Sharepoint    Views: 987

Does anyone have a Visual Basic code written that will do the

We have *.dwg documents that I have put into SPS. I have exported
their metadata and placed it into an Access database (or I could use
an Excel spreadsheet).

I need a code that will take each *.dwg document and pull in their
custom data from the Access database and populate the profile which I
have created.

(Obviously since these aren't Microsoft documents the profile
information doesn't get pulled in automatically.)

I tried to use the code from the SDK, but can't seem to get it to



6 Answers Found

Answer #1    Answered By: Bhairavi Damle     Answered On: Mar 03

Can we see what you have?????

Answer #2    Answered By: Leeann Hull     Answered On: Mar 03

I sent the script code  to your personal email address.

Answer #3    Answered By: Vaasu Radhakrishna     Answered On: Mar 03

I am also trying to get the data  from access  database and populate  the
metadata for that document’s profiles in sps  with that data. Can I also
have a look at your code. As I have written something of mine. But would
be realy helpful if you could provide me with yrs.

Answer #4    Answered By: Brinda Bca     Answered On: Mar 03

As a preference, I have 3 items in my Access file for each drawing
that I need to pull  over: Item No., Category and Description. Each
item will differ for each drawing. I am not sure how this code  will
know which information goes with which drawing. Perhaps if someone
gets this code to work, than they can explain it further to me. I've
been banging my head against a wall with this one, so any help is
greatly appreciated!!

Here is the code that I borrowed from another user and am trying to
tweak for my own usage:

Sub test()
'Create SQL Query to extract records
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim Filename As String
Filename = "C:\Documents and Settings\lfine\Drawings.mdb"
rst.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.3.51; " & _
"Data Source=" & Filename
rst.Source = "SELECT * FROM Test"
rst.Open Options:=adCmdText

While Not rst.EOF

'MsgBox (rst.Fields("RECord_Number"))
Dim File
File = Trim(rst.Fields("RECord_Number")) & ".tif"

Dim oDocument As PKMCDO.KnowledgeDocument
Set oDocument = New PKMCDO.KnowledgeDocument
Dim sPath As String

Dim sErr As String
On Error Resume Next
sPath = "http://aec-portal/Test_Workspace/Documents/Drawings/"
& File & _
oDocument.DataSource.Open sPath, , adModeReadWrite
If Err.Number = 0 Then 'Error if you don't have
permission or if
'document doesn't exist

'Bind to the WSS (web storage system) copy of the document
Dim oDoc1 As PKMCDO.KnowledgeDocument
Set oDoc1 = New PKMCDO.KnowledgeDocument
oDoc1.DataSource.Open sPath, , adModeReadWrite, , , "", ""

'Create KnowledgeVersions object. This will be used to
'Checkout, Checkin, and Publish the document  from the WSS
Dim oVersion As PKMCDO.KnowledgeVersion
Set oVersion = New PKMCDO.KnowledgeVersion

'Check Out the document. Checking out a document places an
'editing reservation on the document
Dim oRS As ADODB.Recordset
Set oRS = oVersion.Checkout(sPath)

'Get the working copy name
'The urn used is = String property containing a URL to the
working copy
'of the document
Dim sWorkingCopy As String
sWorkingCopy = oRS.Fields("urn:schemas-microsoft-

'Bind to the working copy of the document
Dim oDoc2 As PKMCDO.KnowledgeDocument
Set oDoc2 = New PKMCDO.KnowledgeDocument
oDoc2.DataSource.Open sWorkingCopy, , adModeReadWrite

'Set properties on object
oDoc2.Property("Item Number") = "" & rst.Fields("ITEM NO") & ""
Number") = "" _
& rst.Fields("ITEM NO") & ""

oDoc2.Property("Category") = "" & rst.Fields("CATEGORY") & ""
microsoft.com:office:office#Category") = "" _
& rst.Fields("CATEGORY") & ""

oDoc2.Property("Product Description") = "" & rst.Fields
Description") = "" _
& rst.Fields("DESCRIPTION") & ""


'Save changes

'Checkin and publish document to WSS
'A checkin releases the editing reservaton placed on the
document when
'it was checked out, and updates the content of the document.
oVersion.Checkin sPath

'This method submits the document for publication. If there is
'defined for the document, the workflow is initiated. If there
'noworkflow, the document is approved as the new default
oVersion.Publish sPath

'Set oDoc1 = Nothing (not really required for visual  basic)
'Set oDoc2 = Nothing
'Set oVersion = Nothing
'Set oRS = Nothing
End If


MsgBox ("Finished")

End Sub

Private Sub Command1_Click()
Call test
End Sub

Answer #5    Answered By: Sheryl Velez     Answered On: Mar 03

More information...the user who originally created  this script said
it worked fine - except that in order for the changes to take effect,
you have to manually go to each document, check it out and then back
in and then the custom metadata  will work. (I could probably live
with that for now...I just need the metadata!)

Didn't find what you were looking for? Find more on Code Needed Or get search suggestion and latest updates.