Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject produces error
Am trying to automate QMF which accepts OLE automation through API and have started with IBM's sample code (see below). It seems to fail at the very first stage with the line Set QMFWin = CreateObject("QMFWin.Interface.2") producing the error - 'ActiveX component can't create object or return reference to object'. I have checked Tools:References and tried to select everything applicable but there is nothing specifically for QMF. Am using QMF 7.1 and Excel 2000. Any ideas? Thx, Robert Sub Example1() Dim QMFWin As Object Dim Result As Variant Dim ColHeadings As Variant Dim Cellval As Variant Set QMFWin = CreateObject("QMFWin.Interface.2") Stat = QMFWin.InitializeServer("Server1", "", "", True) If Not (Stat = 0) Then MsgBox ("InitializeServer Failed. " + QMFWin.GetLastErrorString()) Exit Sub End If QueryID = QMFWin.InitializeQuery(0, "select * from q.staff") If QueryID < 0 Then MsgBox ("InitializeQuery Failed. " + QMFWin.GetLastErrorString()) Exit Sub End If Stat = QMFWin.Open(QueryID, 0, False) If Not (Stat = 0) Then MsgBox ("Open Failed. " + QMFWin.GetLastErrorString ()) Exit Sub End If Ncolumns = QMFWin.GetColumnCount(QueryID) Stat = QMFWin.GetColumnHeadings(QueryID, ColHeadings) If (Stat = 0) Then RowIndex = 1 ColIndex = 0 For Each strval In ColHeadings Sheets(1).Cells(RowIndex, ColIndex + 1).Value = strval ColIndex = ColIndex + 1 Next Else MsgBox ("GetColumnHeadings failed. " + QMFWin.GetLastErrorString()) Exit Sub End If GetNextRow = True RowIndex = 2 While GetNextRow = True Stat = QMFWin.FetchNextRow(QueryID, Result) If (Stat 0) Then GetNextRow = False MsgBox ("FetchNextRow failed. " + QMFWin.GetLastErrorString()) Exit Sub ElseIf (stat = -1) Then ' End of result set or empty result set. GetNextRow = False If (RowIndex = 2) Then MsgBox ("Empty result set.") End If Else ColIndex = 1 For Each Cellval In Result Sheets(1).Cells(RowIndex, ColIndex).Value = Cellval ColIndex = ColIndex + 1 Next RowIndex = RowIndex + 1 End If Wend Stat = QMFWin.Close(QueryID) If Not (Stat = 0) Then MsgBox ("Close Failed.") Exit Sub End If MsgBox ("Query complete.") End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2002 produces error in calculation. | Excel Discussion (Misc queries) | |||
Refresh produces #N/A error | Links and Linking in Excel | |||
Refresh produces #N?A error | Excel Discussion (Misc queries) | |||
Adding more than 3 cells (2003)produces "0" but no error message | Excel Worksheet Functions | |||
Createobject returns null in Excel | Excel Discussion (Misc queries) |