I’ve used Dave’s code to identify the list of objects used in a report. Thanks !!!
I want to list in a csv file all the objects used in the conditions of each dataprovider of a set of document.
I have a problem with dataprovider with no conditions.
My code is not correct. I just want to go to the next dataprovider if there is no condition.
my code is :
If MyDocument.DataProviders.Queries.Item(j).Conditions.Count >= 1 Then Print MyDocument.DataProviders.Queries.Item(j).Conditions.Item(l).Object
End if
j is the number of dataprovider
l the number of conditions
Is that your actual code? Wouldn’t the Print need to followed by the file reference (Print #1, for example)? What is the error that you are seeing? Maybe you need to show us more of the code to put things in context … how you’re looping variables (i and j) are controlled, for example.
Sub ConditionsPerDoc()
Dim strCurrentFile As String
Dim docMyDocument As Document
Dim dpMyDataProvider As DataProvider
Dim dpColumn As Column
Dim strName As String
Dim strNextItem As String ' used to parse comma listed table names
Dim strDocPath As String ' Path to use to look for files
Dim strObjList As String ' Path for output file
Dim strUniverseCondition As String
Dim strErrorLog As String ' Path for error log
Dim i, j, k, l As Integer ' loop counters
Dim x As Integer ' function result value
' Start directory list of .rep files in the standard file location. If you want to load files
' from a different directory, you would hard code the value below. Make sure that a hard-coded
' path includes the trailing back slash!
strDocPath = Application.GetInstallDirectory(boDocumentDirectory) & "\"
strObjList = strDocPath & "ConditionsPerDoc.csv"
strErrorLog = strDocPath & "ConditionsPerDoc.log"
If FileExist(strObjList) Then
Kill (strObjList)
End If
If FileExist(strErrorLog) Then
Kill (strErrorLog)
End If
strCurrentFile = Dir(strDocPath & "*.rep")
' Do while there are reports we have not looked at
Do While strCurrentFile <> ""
If strCurrentFile <> ThisDocument.Name & ".rep" Then
Set docMyDocument = Application.Documents.Open(strDocPath & strCurrentFile)
If docMyDocument.Name <> "" Then
For j = 1 To docMyDocument.DataProviders.Count
Set dpMyDataProvider = docMyDocument.DataProviders.Item(j)
If dpMyDataProvider.GetType = "DPQTC" Then ' This is a dataprovider from a universe
' Get the name associated with the data provider
strName = dpMyDataProvider.Name
If dpMyDataProvider.Queries.Item(j).Conditions.Count >= 1 Then
' For Each Cond In dpMyDataProvider.Queries.Item(j).Conditions
Open strObjList For Append As OutNum
For l = 1 To dpMyDataProvider.Queries.Item(j).Conditions.Count
' Get the queries associated with the data provider
strUniverseCondition = dpMyDataProvider.Queries.Item(j).Conditions.Item(l).Object
' Next step will be to parse the data provideres and write out to
' an output file the comma separated list of objects used
Print #OutNum, strName; "; "; strUniverseCondition; ""
' Next Cond
Next l
Close OutNum
End If
End If
Next j ' Next data provider, if any more
End If
docMyDocument.Close
End If
' Get next document, if there is one.
strCurrentFile = Dir
Loop
End Sub
{moderator edit: BBCode formatting added to improve readability of code sample}
this code works when a dataprovider has one or more conditions but doesn’t when there is no conditions !
In the meantime, if you have a tech support ID, take a look at this article. It’s one of my SDK presentations from this past User Conference, and contains a utility that documents all the objects used in a series of report file. Maybe some code from that will give you some ideas.
I’ve only been using BusObj less than four years actually …
And business? Well, I’m not a consultant … my job is in-house. With the persistent downsizing at most corporations (including mine), my “business” is quite good … meaning I’m “swamped” … and I don’t mind at all .