Hey all,
Im tyring to write a VBA that will copy/paste between excel and another program, that program being Attachmate Reflections which also works with VBA macros.
I've built a few test iterations as I am not very familiar with Visual Basic, and I am slowly getting the hang of things however I've run into a problem I cannot seem to solve.
My current test code is as follows:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Test1()
Dim hostSettleTimeout As Integer
Dim hostSettleTime As Integer
Dim ibmCurrentScreen As IbmScreen
Dim ibmCurrentTerminal As IbmTerminal
Dim returnValue As Integer
Dim hiddenTextEntry As String
Dim MyScreen As IbmScreen
hostSettleTimeout = 30000
hostSettleTime = 3000
Set ibmCurrentTerminal = ThisFrame.SelectedView.Control
Set ibmCurrentScreen = ibmCurrentTerminal.Screen
Call ibmCurrentScreen.SetSelectionStartPos(15, 23)
Call ibmCurrentScreen.ExtendSelectionRect(15, 28)
Call ibmCurrentScreen.Copy
AppActivate ("Microsoft Excel")
Sleep 50
SendKeys "^v"
Sleep 50
End Sub
The frustrating part is that this was working moments before I added a line and then removed it. Now it doesn't paste anymore. If I change the "^v" to something simple say, "111" it correctly enters 111 into the active cell in excel, so I don't believe its a timing issue. I have no idea whats happening...
My other issue is that I cant seem to send an ENTER command through SendKeys either. I've tried using {ENTER}, "~", Char13. None worked.
Thanks for any help!
Im tyring to write a VBA that will copy/paste between excel and another program, that program being Attachmate Reflections which also works with VBA macros.
I've built a few test iterations as I am not very familiar with Visual Basic, and I am slowly getting the hang of things however I've run into a problem I cannot seem to solve.
My current test code is as follows:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Test1()
Dim hostSettleTimeout As Integer
Dim hostSettleTime As Integer
Dim ibmCurrentScreen As IbmScreen
Dim ibmCurrentTerminal As IbmTerminal
Dim returnValue As Integer
Dim hiddenTextEntry As String
Dim MyScreen As IbmScreen
hostSettleTimeout = 30000
hostSettleTime = 3000
Set ibmCurrentTerminal = ThisFrame.SelectedView.Control
Set ibmCurrentScreen = ibmCurrentTerminal.Screen
Call ibmCurrentScreen.SetSelectionStartPos(15, 23)
Call ibmCurrentScreen.ExtendSelectionRect(15, 28)
Call ibmCurrentScreen.Copy
AppActivate ("Microsoft Excel")
Sleep 50
SendKeys "^v"
Sleep 50
End Sub
The frustrating part is that this was working moments before I added a line and then removed it. Now it doesn't paste anymore. If I change the "^v" to something simple say, "111" it correctly enters 111 into the active cell in excel, so I don't believe its a timing issue. I have no idea whats happening...
My other issue is that I cant seem to send an ENTER command through SendKeys either. I've tried using {ENTER}, "~", Char13. None worked.
Thanks for any help!