gpt4 book ai didi

excel - 如何从 VBA excel 代码中解锁 X SYSTEM PCOMM ibm as400 终端?如果不是 autECLOIA.InputInhibited = 0 那么

转载 作者:行者123 更新时间:2023-12-04 20:52:26 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How to make SendKeys act Synchronously in IBM Host Access Library

(1 个回答)


3年前关闭。




我正在运行一个 excel 自动化宏来读取 IbM as400 终端窗口数据。我的宏运行速度比终端窗口快,有时会导致 autECLOIA 控制台消息系统停止并显示红色 X SYSTEM 停止消息。

我试图在我的代码中包含
如果不是 autECLOIA.InputInhibited = 0 那么
声明,但因错误消息而失败。
有人可以帮助我吗?

Option Explicit

'
'<------------- Definitions --------------------------------------------------------------------
'

'main sheet and connectivity declarations
Public DAT As Worksheet
Public CurrentRow As Long

Public autECLSession As Object
Public autECLPS As Object
Public autECLOIA As Object
Public autECLConnList As Object

'main declarations used by forms
Public CompanyID As String
Public Cancel As Boolean
Public Curr As String
Public Route1 As String, Route2 As String

'date variable definitions for entire programm
Public TodaysDate As Date
Public TodaysDateShort As String
Public TodaysDateAS As String
Public TodaysDateQuery As String
Public StartDate As Date
Public EndDate As Date
Public EndDateShort As String
Public EndDateAS As String
Public EndDateQuery As String
Public dateVariable As Date
Public TimeNow As String
Public CurrentDate As Date
Public DateTime As String
Public DateQ As String

'other declarations - minor
Public From As String
Public StartRowST As Byte
Public CountDep As Byte
Public EndRowST As Byte

Public myNewRangeSize As String



'
'<------------- Main subroutine ----------------------------------------------------------------
'
Sub Start()
'definitions and for initialisation
Set DAT = Worksheets("DATA")
Load StartImport
StartImport.Show
If Cancel = True Then Exit Sub

'Accordingly to currency the route changes
If Curr = "PLN" Then
Route1 = "SWITRE"
Route2 = "TRESWI"
Else
Route1 = "KONTRE"
Route2 = "TREKON"
End If

'data transfer functions
'set and format dates
StartEndFormatDates


'start import
If CompanyID = "TT" Then
'code for importing TT-Line data kontinent to trelleborg
CurrentDate = StartDate
Do Until DateValue(CurrentDate) = DateValue(DateAdd("d", 1, EndDate))

EnterSailingTimetableCountOneDaysDepartures Route1, CurrentDate

'MsgBox "CurrentDate = " & CurrentDate & _
'vbCrLf & "StartRowST = " & StartRowST & _
'vbCrLf & "CountDep = " & CountDep & _
'vbCrLf & "EndRowST = " & EndRowST

If StartRowST = 0 And EndRowST = 0 Then
'do nothing
Else
ImportMainST Route1, CurrentDate
End If

'switching route

EnterSailingTimetableCountOneDaysDepartures Route2, CurrentDate

If StartRowST = 0 And EndRowST = 0 Then
'do nothing
Else
ImportMainST Route2, CurrentDate
End If

CurrentDate = DateAdd("d", 1, CurrentDate)
Loop

Else
'enter here code for importing other data

End If

Dim myNewRangeSize As Long

myNewRangeSize = DAT.Range("A1000000").End(xlUp).Row
DAT.ListObjects("DataTable").Resize Range("$A$1:$Z$" & myNewRangeSize)

End Sub

'
'<------------- Main functions -----------------------------------------------------------------
'

'formats start and end dates to 3 formats = Human, AS400 and Query
Function StartEndFormatDates()
'Work on todays date
TodaysDate = Format(Now, "dd.mm.yyyy")
TodaysDateShort = Format(TodaysDate, "dd.mm.yy")
TodaysDateAS = Format(TodaysDate, "ddmmyy")

Dim DateSplit() As String
DateSplit() = Split(TodaysDate, ".")
TodaysDateQuery = DateSplit(2) & "-" & DateSplit(1) & "-" & DateSplit(0)

'Go to calendar to pick a date for outbound
'AdvancedCalendar 'checked
'Check if any date chosen from calendar
If EndDate < TodaysDate Then 'if user closes calendar without picking a date the program ends here
'SendKeys2Extra "[pf3]"
MsgBox ("You ended. Thank you.")
Call ObjEndExtra
Exit Function
End If

'EndDate = Format(dateVariable, "dd.mm.yyyy")
EndDateShort = Format(EndDate, "dd.mm.yy")
EndDateAS = Format(EndDate, "ddmmyy")

DateSplit() = Split(EndDate, ".")
EndDateQuery = DateSplit(2) & "-" & DateSplit(1) & "-" & DateSplit(0)
'DispMsg (EndDate)

'time now
TimeNow = Format(Now, "hh:mm")
End Function

'enters ST in book window on given route and date --> counts first ST row and the number of departures
Function EnterSailingTimetableCountOneDaysDepartures(Rou As String, CheckDate As Date)
'get into ST
SendStr Left(Rou, 3) & Right(Rou, 3), 5, 9
SendStr Format(CheckDate, "ddmmyy"), 5, 23
Send "enter"
'
'<@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ here I would want something like this @@@@@@@@@@@@@@@@@@@@@@@@@:
'If not autECLOIA.InputInhibited = 0 Then
' send "reset/ctrl"
'end if
'<=================================== but it doesn't work - generating object errors

'define variables
StartRowST = 0
CountDep = 0
EndRowST = 0
DateTime = ""
Dim i As Byte, stopif As Boolean
stopif = False

'start loop through ST screen to compare dates and time
For i = 1 To 18
autECLSession.autECLOIA.WaitForInputReady
'
'

FromAS 5 + i, 17, 8
'MsgBox "In search for last row:" & _
'vbCrLf & "From = " & CDate(Format(From, "dd.mm.yyyy")) & _
'vbCrLf & "Checkdate+1 day = " & CDate(DateAdd("d", 1, CheckDate))
Dim Spl() As String
Spl() = Split(From, ".")
From = Spl(0) & "." & Spl(1) & ".20" & Spl(2)

If CDate(From) = CDate(DateAdd("d", 1, CheckDate)) Then
'counts where is last Row in ST
If EndRowST > 0 Then
EndRowST = EndRowST - 1
Exit For
Else
Exit For
End If
Else
'read and set DateTime for determininig first row in ST
'FromAS 5 + i, 17, 8
DateTime = Format(From, "dd.mm.yyyy")
FromAS 5 + i, 32, 5
DateTime = DateTime & " " & Replace(From, ".", ":")
'MsgBox "DateTime = " & DateTime & _
'vbCrLf & "CheckDate = " & CheckDate & _
'vbCrLf & "Todaysdate+TimeNow = " & TodaysDate & " " & TimeNow

'check if DateTime read from ST bigger then Now - if so then counting first row and departures
If (CDate(DateTime) > CDate(TodaysDate & " " & TimeNow)) And StartRowST = 0 Then
StartRowST = 5 + i
CountDep = CountDep + 1
EndRowST = StartRowST
ElseIf (CDate(DateTime) < CDate(TodaysDate & " " & TimeNow)) And StartRowST = 0 Then
stopif = True
ElseIf (CDate(DateTime) > CDate(TodaysDate & " " & TimeNow)) And StartRowST > 0 Then
CountDep = CountDep + 1
End If

If stopif = False Then
EndRowST = EndRowST + 1
End If
End If
Next i

'exits ST details to first ST screen to be ready for checking next date
Send "pf3"
End Function

Function ImportMainST(Rou As String, CheckDate As Date)
'get into ST
SendStr Left(Rou, 3) & Right(Rou, 3), 5, 9
SendStr Format(CheckDate, "ddmmyy"), 5, 23
Send "enter"
'
'


Dim i As Byte, j As Integer, x As Integer, y As Byte, startI As Integer

Dim Dep As String, Arr As String, WeekD As String, DepTime As String, Ship As String, _
WL As String, Canc As String, Price As String, BookedPax As String, Deck As String, _
FreePAX As String, FreeLPpax As String, MIS1 As Integer, MIS10 As Integer, _
MIS20 As Integer, MIS30 As Integer ', BPax As Integer

Dim Typ(19) As String
Dim BNAmo(19) As String 'booked normal cabins - type and amount
Dim KLAmo(19) As String 'booked komf/lux cabins sum
Dim FNAmo(19) As String 'free normal cabins sum
Dim FKLAmo(19) As String 'free komf/lux cabins sum
Dim FLPAmo(19) As String 'free low price cabins sum


Dim BNSum As Integer 'booked normal cabins sum
Dim KLSum As Integer 'booked komf/lux cabins sum
Dim FNSum As Integer 'free normal cabins sum
Dim FKLSum As Integer 'free komf/lux cabins sum
Dim FLPSum As Integer 'free low price cabins sum

startI = 1
'importing main ST screen
For i = StartRowST To EndRowST
CurrentRow = DAT.Cells(Rows.count, 1).End(xlUp).Row + 1

'<-------- Sail.Time: X -------->
If startI = 1 Then
'do nothing
Else
SendStr "X", 25, 31
Send "enter"
'
'


End If

'A date of entry - todaysdate
DAT.Range("A" & CurrentRow) = TodaysDate

'B compnay - CompanyComboBox
DAT.Range("B" & CurrentRow) = CompanyID

'C Dep
FromAS i, 6, 9
Dep = Left(From, 3)
DAT.Range("C" & CurrentRow) = Dep

'D Arr
Arr = Right(From, 3)
DAT.Range("D" & CurrentRow) = Arr

'E Dep date - CurrentDate
DAT.Range("E" & CurrentRow) = CurrentDate

'F Weekday
'FromAS i, 27, 2
'WeekD = From
DAT.Range("F" & CurrentRow) = Weekday(CurrentDate)

'G Time
FromAS i, 32, 5
DepTime = Replace(From, ".", ":")
DAT.Range("G" & CurrentRow) = DepTime

'Z Dep timeframe
If DepTime >= TimeValue("05:00:00") And DepTime < TimeValue("13:00:00") Then
DAT.Range("Z" & CurrentRow) = "Morning"
ElseIf DepTime >= TimeValue("13:00:00") And DepTime < TimeValue("19:00:00") Then
DAT.Range("Z" & CurrentRow) = "Afternoon"
ElseIf DepTime >= TimeValue("19:00:00") And DepTime < TimeValue("00:00:00") Then
DAT.Range("Z" & CurrentRow) = "Evening"
ElseIf DepTime >= TimeValue("00:00:00") And DepTime < TimeValue("05:00:00") Then
DAT.Range("Z" & CurrentRow) = "Night"
End If

'H Ship
FromAS i, 39, 2
Ship = From
DAT.Range("H" & CurrentRow) = Ship

'I WL
FromAS i, 59, 3
If Trim(From) <> "" Then WL = From
DAT.Range("I" & CurrentRow) = WL

'J Canc
FromAS i, 72, 4
If Trim(From) <> "" Then Canc = From
DAT.Range("J" & CurrentRow) = From

If DAT.Range("J" & CurrentRow) <> "CANC" Then
'K - Price
FromAS i, 85, 4
Price = Trim(From)
DAT.Range("K" & CurrentRow) = Price

'L - Currency from CurrencyComboBox
DAT.Range("L" & CurrentRow) = Curr


'<-------- Cabin-Av: B -------->
SendStr "B", 25, 43
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


'M booked PAX
FromAS i, 27, 3
If IsNumeric(Trim(From)) = True Then
BookedPax = Trim(From)
Else
BookedPax = 0
End If
DAT.Range("M" & CurrentRow) = BookedPax

'T - Booked Cab
BNSum = 0
x = 0
For j = 0 To 19
FromAS 5, 32 + x, 4
Typ(j) = Trim(From)
FromAS i, 32 + x, 4
BNAmo(j) = Trim(From)

If IsNumeric(Trim(BNAmo(j))) = True Then
'MsgBox "Right(Trim(Typ(j)), 1) = " & Right(Trim(Typ(j)), 1) & vbCrLf & "Trim(Typ(j) = " & Trim(Typ(j))
If (Right(Trim(Typ(j)), 1) <> "K" Or Right(Trim(Typ(j)), 1) <> "L") And (Trim(Typ(j)) <> "LOUN" Or Trim(Typ(j)) <> "PULL") Then
BNSum = BNSum + CInt(BNAmo(j))
End If
End If

x = x + 5
'MsgBox Typ(j) & " = " & BNAmo(j)
Next j
DAT.Range("T" & CurrentRow) = BNSum


'U - Booked K/L Cab
KLSum = 0
x = 0
For j = 0 To 19
FromAS i, 32 + x, 4
KLAmo(j) = Trim(From)

If IsNumeric(Trim(KLAmo(j))) = True Then
If (Right(Trim(Typ(j)), 1) = "K" Or Right(Trim(Typ(j)), 1) = "L") And (Trim(Typ(j)) <> "PULL" Or Trim(Typ(j)) <> "LOUN") Then
KLSum = KLSum + CInt(KLAmo(j))
End If
End If


x = x + 5
'MsgBox Typ(j) & " = " & KLAmo(j)
Next j
DAT.Range("U" & CurrentRow) = KLSum




'<-------- Cabin-Av: X -------->
SendStr "X", 25, 43
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


'R free PAX
FromAS i, 27, 3
If IsNumeric(Trim(From)) = True Then
FreePAX = Trim(From)
Else
FreePAX = 0
End If
DAT.Range("R" & CurrentRow) = FreePAX

'V - Free Cabins
FNSum = 0
x = 0
For j = 0 To 19
FromAS 5, 32 + x, 4
Typ(j) = Trim(From)
FromAS i, 32 + x, 4
FNAmo(j) = Trim(From)

If IsNumeric(Trim(FNAmo(j))) = True Then
If (Right(Trim(Typ(j)), 1) <> "K" Or Right(Trim(Typ(j)), 1) <> "L" Or Trim(Typ(j)) <> "SU4") And (Trim(Typ(j)) <> "LOUN" Or Trim(Typ(j)) <> "PULL") Then
FNSum = FNSum + CInt(FNAmo(j))
End If
End If


x = x + 5
'MsgBox Typ(j) & " = " & FNAmo(j)
Next j
DAT.Range("V" & CurrentRow) = FNSum

'W - Free K/L Cab
FKLSum = 0
x = 0
For j = 0 To 19
FromAS i, 32 + x, 4
FKLAmo(j) = Trim(From)

If IsNumeric(Trim(FKLAmo(j))) = True Then
If (Right(Trim(Typ(j)), 1) = "K" Or Right(Trim(Typ(j)), 1) = "L" Or Trim(Typ(j)) = "SU4") And (Trim(Typ(j)) <> "PULL" Or Trim(Typ(j)) <> "LOUN") Then
FKLSum = FKLSum + CInt(FKLAmo(j))
End If
End If

x = x + 5
'MsgBox Typ(j) & " = " & FKLAmo(j)
Next j
DAT.Range("W" & CurrentRow) = FKLSum

'<-------- Cabin-Av: L -------->
SendStr "L", 25, 43
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


'S - Free LP PAX
FromAS i, 27, 3
If IsNumeric(Trim(From)) = True Then
FreeLPpax = Trim(From)
Else
FreeLPpax = 0
End If
DAT.Range("S" & CurrentRow) = FreeLPpax

'X - Free LP Cab
FLPSum = 0
x = 0
For j = 0 To 19
FromAS 4, 32 + x, 4
Typ(j) = Trim(From)
FromAS i, 32 + x, 4
FLPAmo(j) = Trim(From)

If IsNumeric(Trim(FLPAmo(j))) = True Then
If Trim(Typ(j)) <> "LOUN" Or Trim(Typ(j)) <> "PULL" Then
FLPSum = FLPSum + CInt(FLPAmo(j))
End If
End If

x = x + 5
'MsgBox Typ(j) & " = " & FLPAmo(j)
Next j
DAT.Range("X" & CurrentRow) = FLPSum


'<--------Deck-Av: X -------->
SendStr "X", 25, 54
Send "Enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


'Y Free Deck
FromAS i, 32, 3
Deck = Trim(From)
DAT.Range("Y" & CurrentRow) = Deck

'<-------- Query -------->

Send "pf3"
Send "pf3"
Send "pf3"
autECLSession.autECLOIA.WaitForInputReady
'
'


SendStr "6", 20, 7
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


SendStr "2", 5, 26
SendStr "KOORDINAT", 9, 28
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


Send "pf4"
SendStr "2A_01GREG", 11, 3
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


SendStr "1", 13, 3
Send "enter"
autECLSession.autECLOIA.WaitForInputReady
'
'


Dim SplQ() As String
SplQ() = Split(CheckDate, ".")
DateQ = SplQ(2) & "-" & SplQ(1) & "-" & SplQ(0)

SendStr DateQ, 7, 36
SendStr Dep, 8, 36
SendStr Arr, 9, 36
SendStr DepTime, 10, 36

'
'

autECLSession.autECLPS.SetCursorPos 12, 35
autECLSession.autECLPS.SetCursorPos 12, 35
autECLSession.autECLOIA.WaitForInputReady
SendStr "'01' ", 12, 35
'
'


autECLSession.autECLOIA.WaitForInputReady
Send "pf5"
autECLSession.autECLOIA.WaitForInputReady
'
'


'N Booked MIS 1
FromAS 6, 7, 1
If IsNumeric(From) Then
FromAS 7, 41, 3
If Trim(From) <> "" Then
MIS1 = Trim(From)
Else
MIS1 = 0
End If
Else
MIS1 = 0
End If
DAT.Range("N" & CurrentRow) = MIS1
'
'


Send "pf3"
autECLSession.autECLPS.SetCursorPos 12, 35
autECLSession.autECLPS.SetCursorPos 12, 35
'
'

autECLSession.autECLOIA.WaitForInputReady
SendStr "'10' ", 12, 35
Send "pf5"
autECLSession.autECLOIA.WaitForInputReady
'
'


'O MIS 10
FromAS 6, 7, 1
If IsNumeric(From) Then
FromAS 7, 41, 3
If Trim(From) <> "" Then
MIS10 = Trim(From)
Else
MIS10 = 0
End If
Else
MIS10 = 0
End If
DAT.Range("O" & CurrentRow) = MIS10
'
'


Send "pf3"
autECLSession.autECLPS.SetCursorPos 12, 35
autECLSession.autECLPS.SetCursorPos 12, 35
'
'

autECLSession.autECLOIA.WaitForInputReady
SendStr "'20' ", 12, 35
Send "pf5"
autECLSession.autECLOIA.WaitForInputReady
'
'


'P MIS 20
FromAS 6, 7, 1
If IsNumeric(From) Then
FromAS 7, 41, 3
If Trim(From) <> "" Then
MIS20 = Trim(From)
Else
MIS20 = 0
End If
Else
MIS20 = 0
End If
DAT.Range("P" & CurrentRow) = MIS20

Send "pf3"

autECLSession.autECLPS.SetCursorPos 12, 35
autECLSession.autECLPS.SetCursorPos 12, 35
'
'

autECLSession.autECLOIA.WaitForInputReady
SendStr "'30' ", 12, 35
Send "pf5"
autECLSession.autECLOIA.WaitForInputReady
'
'


'Q MIS 30
FromAS 6, 7, 1
If IsNumeric(From) Then
FromAS 7, 41, 3
If Trim(From) <> "" Then
MIS30 = Trim(From)
Else
MIS30 = 0
End If
Else
MIS30 = 0
End If
DAT.Range("Q" & CurrentRow) = MIS30
'
'


autECLSession.autECLOIA.WaitForInputReady
Send "pf12"
Send "pf3"
autECLSession.autECLOIA.WaitForInputReady (750)
'
'


autECLSession.autECLOIA.WaitForInputReady
SendStr "N", 5, 29
Send "enter"
'
'


autECLSession.autECLOIA.WaitForInputReady

Send "pf3"
autECLSession.autECLOIA.WaitForInputReady
'
'


SendStr "1", 20, 7
Send "enter"
'
'

autECLSession.autECLOIA.WaitForInputReady
SendStr "13", 20, 7
Send "enter"
'
'

autECLSession.autECLOIA.WaitForInputReady

CheckResource
If CheckResource = True Then
SendStr Left(Rou, 3) & Right(Rou, 3), 5, 9
SendStr Format(CheckDate, "ddmmyy"), 5, 23
Send "enter"
Else
MsgBox "Error. Not in ST. Unlock book window, and go to ST. If macro starts, leave it.", vbOKOnly, "Error"
End If

End If

'
'

startI = startI + 1
Next i

'exits ST details to first ST screen to be ready for checking next date
Send "pf3"
End Function



'<------------------------------- START, STOP FUNCTIONS -------------------------------------
'
' Set up fields need to link to 5250 session - Copy this block into any new Screen Scrapper macro as is
'
Sub ObjGetExtra()
DAT.Unprotect ("Coordination")
'DAT.Select
Set autECLSession = CreateObject("pcomm.auteclsession")
Set autECLPS = CreateObject("PCOMM.autECLPS")
Set autECLOIA = CreateObject("Pcomm.autecloia")
'Set autECLConnList = CreateObject("PCOMM.autECLConnList")
End Sub

Sub ObjEndExtra()
Set autECLSession = Nothing
Set autECLPS = Nothing
Set autECLOIA = Nothing
'Set autECLConnList = Nothing
DAT.Protect ("Coordination")
End Sub


'<------------------------------ FUNCTIONS FOR AS400 PROCESSING --------------------------------

'
' Put the value on the 5250 screen at the position specified
'
Function SendStr(ByVal Data As String, ByVal Row As Long, ByVal Col As Long)
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SetCursorPos Row, Col
autECLSession.autECLPS.SendKeys Data, Row, Col
End Function

'
' Read a string from the 5250 screen strarting at the position specified
'
Function FromAS(ByVal Row As Long, ByVal Col As Long, ByVal Lenght As Long) As String
autECLSession.autECLOIA.WaitForInputReady
From = autECLSession.autECLPS.GetText(Row, Col, Lenght)
End Function

'
' Sent special keys to the session (function keys, enter, etc)
'
Function Send(Key As String)
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[" & Key & "]"
End Function

' Check if in Sailing Timetable
Function CheckResource() As Boolean
FromAS 2, 20, 7
'
'

If Trim(From) = "SAILING" Then
FromAS 4, 11, 5
'
'
'
If Trim(From) = "Route" Then
'do nothing
CheckResource = True
Else
FromAS 4, 2, 3
'
'

If Trim(From) = "Seq" Then
Send "pf3"
CheckResource = True
End If
End If
Else
CheckResource = False
End If

End Function
'the form starting the comm session is here
'StartImport form code
'

Public SessionString As String
'Public handleConn As Byte

Private Sub RunButton_Click()
If CompanyComboBox <> "select" Then
If CompanyComboBox = "TT" And CurrencyComboBox <> "select" Then
If SessionString <> "" Then
'proper start sequence
Call ObjGetExtra
autECLSession.SetConnectionByname (SessionString)
autECLPS.SetConnectionByname (SessionString)
'autECLConnList.Refresh
autECLOIA.SetConnectionByname (SessionString)
If autECLSession.commstarted = False Then
MsgBox "There does not appear to be a session '" & SessionString & "'. Please Check and try again.", vbOKOnly, "Error"
Call ObjEndExtra
End If

Call CheckResource
If CheckResource = True Then
CompanyID = CompanyComboBox
Curr = CurrencyComboBox
StartDate = FromDateF
EndDate = ToDateF
Unload Me
Else
MsgBox "You are not in ST, please start ST in choosen session and start again.", vbOKOnly, "Error"
End If
Else
MsgBox "No Session button choosen.", vbOKOnly, "Error"
End If
ElseIf CompanyComboBox <> "TT" Then
CompanyID = CompanyComboBox
CurrencyComboBox = "EUR"
StartDate = FromDateF
EndDate = ToDateF
Unload Me
End If
Else
MsgBox "Nothing selected to be done", vbOKOnly, "Error"
End If
End Sub

Private Sub Session1_Click()
If Session1 = True Then
SessionString = "A"
'handleConn = 1
Session2 = False
Session3 = False
End If
End Sub

Private Sub Session2_Click()
If Session2 = True Then
SessionString = "B"
'handleConn = 2
Session1 = False
Session3 = False
End If
End Sub

Private Sub Session3_Click()
If Session3 = True Then
SessionString = "C"
'handleConn = 3
Session1 = False
Session2 = False
End If
End Sub

Private Sub CompanyComboBox_Change()
If CompanyComboBox = "TT" Then CurrencyComboBox.value = "select"
End Sub

Private Sub CancelButton_Click()
UserForm_QueryClose 0, 0
End Sub


Private Sub UserForm_Initialize()
'Company choice
With Me.CompanyComboBox
.AddItem "TT"
'rest deleted
End With

'Currency choice
With Me.CurrencyComboBox
.AddItem "EUR"
'rest deleted
End With


End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Call ObjEndExtra
Cancel = True
Unload Me
MsgBox "You ended. Thank you.", vbOKOnly, "Exit"
End
End If
End Sub

你在两行中看到的任何地方:'

应该有一些错误处理,例如(上面的代码):
如果不是 autECLOIA.InputInhibited = 0 那么
发送“重置/ctrl”
万一

但它不起作用 - 生成对象错误

最佳答案

宏的速度必须受到终端屏幕速度的限制。我一直在使用此处显示的解决方案:https://stackoverflow.com/a/33310031/3175562使自动化调用等待终端准备就绪。

关于excel - 如何从 VBA excel 代码中解锁 X SYSTEM PCOMM ibm as400 终端?如果不是 autECLOIA.InputInhibited = 0 那么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55309324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com