Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA problem in excel 2007

Status
Not open for further replies.

piowtrpolo

Programmer
May 23, 2008
8
US
I'm going to do my best to explain the problem I have the best I can.

I am using excel 2007 and the VBA associated with it. I don't think it is visual basic 6.0 or not, the program just says VBA. I created a form and the code associated with it fine, but I ran into a problem when I'm trying to include a winsock box into the form so it can connect to an outside source. I have installed the proper mswinsk.ocx and tried everything I can think of, but I can't add a winsock box to my form. When I do try to add a winsock box to the form I get the error "The subject is not trusted for the specified action." I think the code will work properly if I can just add the winsock box to the form.

Please help me with any advice you have.
 
I followed that setup, but now I get a different error saying "The control could not be created because it is not properly licensed." I'm going to continue looking around for a solution to this new problem. If you have another thread with this problem please let me know. Thank you.
 
The VB6 winsock control is NOT distributable with a design-time license. Hence the message you are getting. These days there is theoretically no legal workaround for this - although if you can find a legit downloadable copy of the free VB5 CCE (control creation edition) and install it on your machine this includes the design-time licence. Note that you would need to install this on any machine that you intend to deploy your application on so that they in turn can use the winsock control (unfortunately VBA is to all intents and purpses always considered to be in design-time mode)
 
I got VB5 CCE and installed it on my machine, but I am still get the same error of no license is found. I tried creating a winsock in VB5 CCE and I get "License information not found.
 
Which suggests it might not be a legit CCE installation ...
 
Alright I finally got it working by using another computer and then transferring the project to my computer. Now I have a problem with the code I'm trying to receive and sending it to the worksheet in excel. I don't know how to put code in, but here is the code I have so far. Every time I try to upload the data I get an error: 91 object variable doesn't exist.

Private Function putDataInExcel(data As String)
'Called from wsTCPDevice_DataArrival
'parses out data from In-Sight and puts it directly into excel spreadsheet

Dim exlWSheet As Object
Dim exlRow As Integer
Dim exlCol As Integer


On Error GoTo excelError

Dim index As Integer
'Dim dataval As String
Dim delim As String
Dim term As String
term = vbCrLf
delim = txtDelimiter

'reset exlRow
exlRow = 4

'get index of first delimiter
index = InStr(data, delim)
While index <> 0
'pick off data and put into excel
exlWSheet.Cells(exlCol, exlRow) = Left(data, index - 1)
'trim data off string
data = Mid(data, index + 1)
exlRow = exlRow + 1
index = InStr(data, delim)
Wend
'trim off termininator and
'get last piece of data into excel
exlWSheet.Cells(exlCol, exlRow) = Mid(data, index + 1, InStr(data, term) - 1)

exlCol = exlCol + 1
Exit Function

excelError:
'Excel is probably closed
MsgBox "Error: Excel was shut down", , "Error: " & Err.number & " " & Err.description

End Function
 
>Dim exlWSheet As Object

At no point do you Set this object (to a spreadsheet). Hence the moment your code reaches

exlWSheet.Cells(exlCol, exlRow) = Left(data, index - 1)

it will error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top