If you post your code for showing the progress in a listbox on a userform then maybe we can get it working.
Here is my macro to grab the data, put it in the send edit - send sheet, and also send the program
Sub Send_to_COM_Port()
Dim dataArray As Variant, r As Integer, c As Integer
Dim SendSheet As Worksheet
Dim lastRow As Long, row As Long
Dim COMport As Integer
Dim rowCells As Range
Dim intPortID As Integer 'Ex. 1, 2, 3, 4 for COM1 - COM4
Dim strBaudRate As String 'Baud Rate
Dim intStopBits As Integer 'Stop Bits
Dim intDataBits As Integer 'Data Bits
Dim strParity As String 'Parity
Dim strMachine As String 'Machine - Fadal, Bosto or Mori Seiki
Dim lngStatus As Long
Dim strData As String
Dim strDataSent As String
Set SendSheet = Sheets("Edit - Send")
strMachine = SendSheet.Cells(1, 13).Value 'can change this to whatever field needs to have the machine type. In this case "M1"
Select Case strMachine
Case "Fadal"
intPortID = 1
strBaudRate = "38400"
intStopBits = 1
intDataBits = 7
strParity = "E"
Case "Bosto"
intPortID = 1
strBaudRate = "19200"
intStopBits = 2
intDataBits = 7
strParity = "E"
Case "Mori Seiki"
intPortID = 1
strBaudRate = "4800"
intStopBits = 2
intDataBits = 7
strParity = "E"
Case Else
MsgBox ("No machine information available")
Exit Sub
End Select
'close the port if it is open
Call CommClose(intPortID)
'Copy cells to SendSheet, removing tabs and spaces
dataArray = Sheets("Edit - Send").Range("A1:A1000")
'For r = 1 To UBound(dataArray, 1)
'For c = 1 To UBound(dataArray, 2)
'dataArray(r, c) = Replace(Replace(dataArray(r, c), vbTab, ""), " ", "")
'Next
'Next
With SendSheet
.Cells.Clear
.Range("A1").Resize(UBound(dataArray, 1), UBound(dataArray, 2)).Value = dataArray
'Delete blank rows
lastRow = .UsedRange.row + .UsedRange.Rows.Count - 1
For row = lastRow To 1 Step -1
If WorksheetFunction.CountA(.Rows(row)) = 0 Then
.Rows(row).EntireRow.Delete
End If
Next
lastRow = .UsedRange.Rows.Count
End With
If MsgBox("Is the machine ready?", vbYesNo) = vbNo Then Exit Sub
Transmitting.Show
' Open COM port
lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _
"baud=" & strBaudRate & " parity=" & strParity & " data=" & intDataBits & " stop=" & intStopBits)
'loop through all the rows of information and write the information
For row = 1 To lastRow
'Create string with the current cell value
strData = SendSheet.Cells(row, 1).Value & vbCrLf
'write to the COM port
lngStatus = CommWrite(intPortID, strData)
strDataSent = strDataSent & strData
'pause between each data send
Application.Wait DateAdd("s", 0.2, Now)
lstitems.Items.Add (strData)
'function surrenders execution of the macro so that the operating system can process other events. The DoEvents function passes control from the application to the operating system
DoEvents
Next
Call CommClose(intPortID)
MsgBox ("The following information was sent to the " & strMachine & ":" & vbCrLf & strDataSent)
End Sub
In the "lstitems.Items.Add (strData)" line it locks up.
I was try to stay in the loop so as it sent to the port, it would list to the listbox.
Hope this helps you understand what I'm trying to do.
If you need, is there a way to send you the excel file?
But I don't want to be too much trouble.
Thanks,
Cam