function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Can't use DescribeSObjects in SF Office Toolkit 4.0

I am attempting to use the DescribeSOBjects using the office toolkit vs. 4.0, and cannot seem to get this to work properly.


Does anyone have some good examples of how to use this method in the VBA editor?




Private Sub GetSObjects_Click()

    Dim Username As String
    Dim Password As String
    Username = ""
    Password = "password"

    Dim sfSession As SForceSession4
    Set sfSession = New SForceSession4
    Dim dsr() As String
    If sfSession.Login(Username, Password) Then
        dsr = sfSession.DescribeSObjects( "Account")
        MsgBox "Invalid Login"
    End If

End Sub


When I run the above line I get an error saying Expected Function or Variable


Even when I change dsr = sfSession.DescribeSObjects( "Account") to


sfSession.DescribeSObjects( "Account"


I still get an error saying: Array passed to DescribeSObject needs to be of type VT_BSTR or BT_VARIANT.


Any help would be appreciated.





Little background on how it works first, then I’ll try to answer your question ;)

The officetoolkit uses a partner api describe object call to get the meta data about any object type you’d like to interact with (account, contact, myFoo).  It calls describe on demand, meaning you reference it, like createObject(“account”) or query(“account”), we go get the meta data (if we don’t already have it, in memory cache that does not get flushed automatically). That’s how you get the correct fields on your particular flavor of account (or myFoo, same idea).

The DescribeSObjects call is an optimization you can use (and cool that you are) to front load a number of object definitions in one go, which is good for you and good for us.  Saves round trips, sfdc transactions, user experience is better, etc.


Anyway, I checked the code.  The error message is not correct, you have to pass an array of strings (not a single like ur example), there is no return value (other than standard error stuff) or an array of var (to all you windows javascripters).


I'm having the same problem, can't seem to successfully pass object string(s) to describeSobjects in VBA/Excel. 


Does this function even work in VBA?  I looked in the Excel Connector source, and it doesn't use it.


The error message is always "DescribeSObject needs to be of type VT_BSTR" even when I pass in literal strings, string variables, string arrays...

  • SFDC.DescribeSObjects("lead", "contact")
  • SFDC.DescribeSObjects(nnn(1),nnn(2))
  • SFDC.DescribeSObjects(nnn)
  • SFDC.DescribeSObjects([new List<String>("lead")])

When I try to use the (deprecated) "describeSObject" the error message simply says "function not available" 


Please, please would somebody put out a code sample in VBA that actually works?  All the docs put code samples in C# and Java, which does us Office API people no good at all.


Been doing some more "thinking" about this...


The (deprecated) describeSObject function is at least trying to do something

    Dim dsr as object

    ' SFDC is the binding/session, which is known to be working

    dsr = SFDC.describeSObject("Lead")

Yields "Object doesn't support this property or method" error message.


So maybe the problem is on the left side of the equal sign, not the right...where dsr can't just be a generic VB object.  After much noodling around:

     Dim dsr As SForceOfficeToolkitLib4.SObject4

but then this statement

         dsr = SFDC.describeSObject("Lead")

generates a VB compiler error along the lines of "you can't do that"


so then I go to

         set dsr = SFDC.describeSObject("Lead")

which the VB compiler accepts, but now I'm back to the "Object doesn't support this property or method" error message.




Anyone have an example?

Was there a solution for this?




The DescribeSObjects in toolkit 4 needs an array of string like dim myArray(0 to 1) of String.

myArray(0) = "Object1", myArray(1) = "Object2"



 mySForceSession4.DescribeSObjects (myArray) will work.


But the problem is: in VBA it is a Sub not a function, then it is not usefull. Even more, there is no type in VBA like: DescribeSObjectResult (the return type of the function in Java)


Please, if anyone knows a solution to describe SObjects in VBA (Excel for instance) let us know




Hi all,


I don't think the issue here is the DescribeSObject(string) or DescribeSObjects(string array) method.


The result set of a DescribeSObjects should be in the object that SFDC gives us in VBA:


Dim DescribeSobjectResult As SForceOfficeToolkitLib3.SObject3


Dim DescribeSobjectResults(0 To 1) As SForceOfficeToolkitLib4.SObject4

(the 0 to 1 is arbitrary, you could make it 0 to 100)


So you should be able to assign the results of running the method like this:


Set DescribeSobjectResult = SFDC.DescribeSObject("Lead")

where "SFDC" is the connection to Salesforce.


I don't know why it doesn't work, but it doesn't.  The compiler is OK, but at run time the error just says "the object doesn't support this property or method"...but it doesn't indicate WHICH object doesn't support it....






the execution of this "Set DescribeSobjectResult = SFDC.DescribeSObject("Lead")" will fail with the message "the object doesn't support this property or method"


In the DLL (the toolkit), this type SForceSession4 do not have a method or a property named DescribeSObject - in singular, not plural.


Even when in the PDF manual the function is documented.




the DescribeSObjectResult method is available in v3 of the toolkit.


it's deprecated in v4, but still works in the older one.


of course, "works" is just a theory.  I still have yet to get a successful execution of it in VBA, using either toolkit.