In a message dated 99-03-09 11:06:12 EST, you write:
It contains something like that :
set DataProv = ActiveDocument.DataProviders for i = 1 to dataprov.count set DataProvide = ActiveDocument.DataProviders.Item(i)
I want to insert a test like “if DataProvide.universename <> “” then
…”
but this line gives me an “Invalid DataProvider type” error.
There is a way to determine what type of data provider you are working with.
It is the GetType() function. Documented in the BO Scripting help file as:
Definition Function GetType() As String
Syntax objectvar.GetType
Description Returns the type of this data provider.
Use With OLE Automation: YES ReportScript: YES
However, they do not provide a list of possible types that this function can
return. So, what you would have to do is create a document that has four
different data providers (or as many as you want to test) and see what the
function response is for each one.
In other words, create a document with a query based on a universe. Write a
small script that shows you via a MsgBox command what the GetType() function
reports for that query. That gives you something to test in the script that
you are trying to write. You can do the same thing to test for personal data
files or for free hand SQL if those are used in your environment. I wrote the
script shown below to do this:
Sub Main()
Dim DPList as BODataPRoviders ’ List of data providers in a
document
Dim DP as BODataProvider ’ Individual data provider
variable
Dim i as integer ’ looping counter variable
Dim DPType as String ’ place to store data provider
type
set DPList = ActiveDocument.DataProviders ’ Obtain current document data
providers
for i = 1 to DPList.Count ’ Start looping…
’ Get a data provider…
set DP = ActiveDocument.DataProviders.Item(i)
DPType = DP.GetType() ’ … get its type, then
’ tell the user what type it
is.
MsgBox "For Data Provider " & DP.Name & " the type reported was " &
DPType
If DPType = “DPQTC” Then ’ If the dp type is “universe”, display
universe name
MsgBox "Universe Name is " & DP.UniverseName
End If
Next i ’ continue looping until done
msgbox “Done” ’ Last provider has been
processed
end sub ’ Main Routine Done here
Note: if you copy and paste the script text into a fixed width editor like
notepad you may have more luck reading the file. When I created a document
with a universe query, a personal data file query, and a free hand SQL query
(I don’t have access to Stored Procedures) the following types were reported:
Universe : DPQTC
Personal: DPASCC
Free Hand: DPSQLC
Note: the Personal data file type was reported as DPASCC no matter what type
of file used. I tested CSV, TXT, and XLS. All reported the same type. I was
suspicious when I saw DPASCC that it would only be for ASCII, but it is
reported for all personal data file types that I tested.
It would be nice if these return values were documented in the help file (hint
to Business Objects folks…)
Hope this helps!
Regards,
Dave Rathbun
Integra Solutions
www.islink.com
Listserv Archives (BOB member since 2002-06-25)