CrashOverRideZX Posted May 15, 2006 Share Posted May 15, 2006 K so I am making COM calls to an automation dll. The call requests for two arrays to be passed ByRef Values As Variant and Errors as Long When ever I make the call I am told there is a TypeMismatch but I know that all but these two variables are the problem. Here is a example in VBA Note the Matrikon.OPC.HDAAutomation com object is referenced in Access Option Base 1 Option Explicit Sub WriteOne() Dim HDAServer As OPCHDAServer Dim HDAItem As OPCHDAItems Dim Value Dim Test Dim Style Dim Title Dim tstValue Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons. Title = "MsgBox Demonstration" ' Define title. 'Connect to OPC sim server Set HDAServer = New OPCHDAServer HDAServer.Connect "Matrikon.OPC.DesktopHistorian" 'Add one item Set HDAItem = HDAServer.OPCHDAItems HDAItem.AddItem "Random.Int4", 1 'Client Handle is 1 Dim ItemHandle(1) As Long Dim ReturnValues() As Variant Dim Errors() As Long 'only one item ItemHandle(1) = HDAItem(1).ServerHandle HDAItem.SyncReadRaw "NOW-50D", "NOW", 0, True, 1, ItemHandle, ReturnValues, Errors For Each Value In ReturnValues For Each tstValue In Value Test = MsgBox(tstValue, Style, Title) Next tstValue Next Value End Sub The HDAItem.SyncReadRaw call works fine here When I attempt the same with AutoIT I get the COM Error Link to comment Share on other sites More sharing options...
ptrex Posted May 16, 2006 Share Posted May 16, 2006 @CrashOverRideZX Your are not using a COM error handler to figure out where the error ocurs. Look in my signature for Example "MS Log Parser" code. In there you will find an Com Error handler example. This will bring you a little further, to point out what is wrong. Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
CrashOverRideZX Posted May 16, 2006 Author Share Posted May 16, 2006 You were looking at the VBA code..... My AutoIT script does have a COM Error handler It always reports that there is a Type Mismatch Now after looking deeper it is looking for three things were there may be a problem ServerHandles Array of Longs ByRef Values Array of OPCHDAHistory objects containg OPCHDAEntry objects ByRef Errors Array of Longs So the type mismatch is here somewhere and I am not sure if we can explictly set datatypes in AutoIT I have also tried this out with Perl and have been able to make this work when setting datatype I also was wondering if with all the complications of using this dll/COM Object if it would be easier to write this script using DllCall? Link to comment Share on other sites More sharing options...
ptrex Posted May 17, 2006 Share Posted May 17, 2006 So the type mismatch is here somewhere and I am not sure if we can explictly set datatypes in AutoITI not quit sure but there are no data types in AutoIT.Best is to look in the Help file (search for DIM) or to open a new question in this support section,asking explicitely how to set the datatypes.Dllcall has more options, but is more complicated to find your way through.Regards Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now