Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2002 produces error in calculation. Wes at CCC Excel Discussion (Misc queries) 4 November 16th 07 08:54 PM
Refresh produces #N/A error RhysPieces Links and Linking in Excel 1 July 11th 07 07:42 PM
Refresh produces #N?A error RhysPieces Excel Discussion (Misc queries) 1 July 10th 07 09:16 AM
Adding more than 3 cells (2003)produces "0" but no error message garden girl Excel Worksheet Functions 4 August 30th 06 02:11 PM
Createobject returns null in Excel [email protected] Excel Discussion (Misc queries) 1 March 27th 06 04:04 AM


All times are GMT +1. The time now is 08:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"