I have some reports in a directory and I have to rename the DataProviders of its reports.
How can I do it???
I put this code to prove but if I put the sentences dpMyDataProvider.Load I receive the error Error loading the DataProvider and if I doesnt put it, I not received error but the DataProviders Names of the reports arent modified!!!
What happens? How can I rename the DataProviders???
Dim ArrayNames(5)
ArrayNames = Array("A", "B", "C", "D", "E", "F")
…
…
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 = ThisDocument.DataProviders(1)
'dpMyDataProvider.Load
dpMyDataProvider.Name = ArrayNames(j - 1)
'dpMyDataProvider.Unload
Application.Interactive = False
dpMyDataProvider.Refresh
Application.Interactive = True
Next j ' Next data provider, if any more
End If
docMyDocument.Save
docMyDocument.Close
End If
' Get next document, if there is one.
strCurrentFile = Dir
Loop
mg (BOB member since 2004-01-07)