Weird happenings when connecting to Business Objects

minette

Board Regular
Joined
Jul 8, 2005
Messages
234
Hi all

Wondering if anyone can help me, as I'm stumped.

I have the following code. It works fine from my personal macro folder (PERSONAL.XLS). However, I would like the code to run from a specific file. However, when trying to do that - I get this error:-

Compile Error:
User-defined type not defined

It's exactly the same code - has anyone got any ideas? Please??

Sub GetData1()
Dim BOApp As busobj.Application
Dim Doc As busobj.Document
Dim DataProv As busobj.DataProvider
Dim i As Long, j As Long
Dim strFileName

strFileName = "R:\CONFIDENTIAL\Document3.rep"

Set BOApp = New busobj.Application
BOApp.Visible = False
Call BOApp.LoginAs
Set Doc = BOApp.Documents.Open(strFileName)
Set DataProv = Doc.DataProviders(1)

For i = 1 To DataProv.Columns(1).Count
For j = 1 To DataProv.Columns.Count
ActiveSheet.Cells(i, j) = DataProv.Columns(j).Item(i)
Next j
Next i

BOApp.Quit
Set BOApp = Nothing
MsgBox "done"
End Sub
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

minette

Board Regular
Joined
Jul 8, 2005
Messages
234
Andrew - that's it!!!!

Thank you very much. I didn't realise I had to set the library in each workbook. I thought as soon as you set it in VBA, it will be there for all workbooks etc.

You are great. Thanks very much!
 

Watch MrExcel Video

Forum statistics

Threads
1,113,952
Messages
5,545,143
Members
410,666
Latest member
Al3cs
Top