I have a list that uses multiple content types and I am uploading bulk changes to the list from an excel document via VBA and the ADODB.recordset.

I can edit existing records without any issues. However, when creating new, I cannot specify the content type: the Content Type field is readable but I am unsuccessful in writing to it - all records created are the default content type.

Can anyone offer any pointers on my code?

Private Sub ConnectWorklist()

    Set SPConnection = New ADODB.Connection
    Set SPRecordSet = New ADODB.Recordset

    Dim SQLQuery As String
    SQLQuery = "SELECT * FROM [" & listGUID & "];"

    With SPConnection
        .ConnectionString = _
            "Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=0;RetrieveIds=Yes;" & _
            "DATABASE=" & sharepoint_url & _
            ";LIST=" & listGUID & ";"
    End With

    SPRecordSet.Open SQLQuery, SPConnection, adOpenDynamic, adLockOptimistic

    With SPRecordSet


       ![Title] = Title
       ![External ID] = ExternalID
       ![Content Type] = "Project"

   End With


End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.