Re: WRQ Reflection/VBA copy read data to Excel
See how to use WinSCP .NET assembly from VBA:
https://winscp.net/eng/docs/library_vb
https://winscp.net/eng/docs/library_vb
Hello everybody,
I'm trying to read out text information out of a reflection session.
The lines are stored in strData and I can see all the textlines in the Locals window.
There is however a problem I can't solve no mather how hard I try.
My programming skills are these from a beginner.
After the textstrings are stored in the variable strData I would like to copy them into an Excel sheet.
If all the textlines are copy-d then I would like to send that sheet with an Email to a group of people. All this by using VBA
Can anybody help me please
Here's is an example of the code I've already have(It was ever written by someone else):
'Inlezen rapport SPRRA
'Sessie : Reflection Newbase sessie,cursor staat op het in te lezen rapport in het SPRRA scherm
'Resultaat : 1 dimensionele array van de lijnen van het betreffende rapport
Private Function fPick_Rep(Sessie As Reflection4.Session) As Variant
Dim strData() As String, i As Integer, j As Integer, r As Integer, l As Long, t As Long, s As Long
ReDim strData(0 To 0)
With Sessie
Dim strWacht(1 To 2) As String
strWacht(1) = VBA.Chr(VBA.Asc(vbLf)) + ":" 'vbLf is een linefeed
strWacht(2) = VBA.Chr(VBA.Asc(vbLf)) + "(EOF):"
Sessie.DisplayMemoryBlocks = 10 'geheugen wordt hier vergroot
Sessie.DisplayMemoryBlocks = 9 'hier terug verlaagd
.Transmit "b"
Do
j = Sessie.Application.WaitForStrings(strWacht, 5)
If j = 0 Then
MsgBox "Er liep iets mis !"
Exit Function
Else
r = .cursorRow 'kijkt waar de cursor staat en stopt dit in var.r
l = UBound(strData) 'om de bovenkant van de file aan te geven
s = 0
ReDim Preserve strData(0 To l + r - VBA.IIf(l = 0, 1, 0) + VBA.Abs(Sessie.DisplayMemoryTopRow))
t = VBA.IIf(l = 0, 0, 1)
For i = Sessie.DisplayMemoryTopRow To r - 1
strData(l + s + t) = .GetText(i, 0, i, .DisplayColumns)
s = s + 1
Next
End If
'Even schermhegeheugen resetten
Sessie.DisplayMemoryBlocks = 10
Sessie.DisplayMemoryBlocks = 9
.Transmit VBA.Chr(13) 'character 13 is een carriage return
DoEvents
'Als j = 2 dan hebben we het einde bereikt
If j = 2 Then
.WaitForString "DETAIL"
Exit Do
End If
Loop
End With
fPick_Rep = strData
End Function
Public Sub leesrapport()
Dim varData As Variant
varData = fPick_Rep(Me)
End Sub
Nick
Hello everybody,
I'm trying to read out text information out of a reflection session.
The lines are stored in strData and I can see all the textlines in the Locals window.
There is however a problem I can't solve no mather how hard I try.
My programming skills are these from a beginner.
After the textstrings are stored in the variable strData I would like to copy them into an Excel sheet.
If all the textlines are copy-d then I would like to send that sheet with an Email to a group of people. All this by using VBA
Can anybody help me please
Here's is an example of the code I've already have(It was ever written by someone else):
'Inlezen rapport SPRRA
'Sessie : Reflection Newbase sessie,cursor staat op het in te lezen rapport in het SPRRA scherm
'Resultaat : 1 dimensionele array van de lijnen van het betreffende rapport
Private Function fPick_Rep(Sessie As Reflection4.Session) As Variant
Dim strData() As String, i As Integer, j As Integer, r As Integer, l As Long, t As Long, s As Long
ReDim strData(0 To 0)
With Sessie
Dim strWacht(1 To 2) As String
strWacht(1) = VBA.Chr(VBA.Asc(vbLf)) + ":" 'vbLf is een linefeed
strWacht(2) = VBA.Chr(VBA.Asc(vbLf)) + "(EOF):"
Sessie.DisplayMemoryBlocks = 10 'geheugen wordt hier vergroot
Sessie.DisplayMemoryBlocks = 9 'hier terug verlaagd
.Transmit "b"
Do
j = Sessie.Application.WaitForStrings(strWacht, 5)
If j = 0 Then
MsgBox "Er liep iets mis !"
Exit Function
Else
r = .cursorRow 'kijkt waar de cursor staat en stopt dit in var.r
l = UBound(strData) 'om de bovenkant van de file aan te geven
s = 0
ReDim Preserve strData(0 To l + r - VBA.IIf(l = 0, 1, 0) + VBA.Abs(Sessie.DisplayMemoryTopRow))
t = VBA.IIf(l = 0, 0, 1)
For i = Sessie.DisplayMemoryTopRow To r - 1
strData(l + s + t) = .GetText(i, 0, i, .DisplayColumns)
s = s + 1
Next
End If
'Even schermhegeheugen resetten
Sessie.DisplayMemoryBlocks = 10
Sessie.DisplayMemoryBlocks = 9
.Transmit VBA.Chr(13) 'character 13 is een carriage return
DoEvents
'Als j = 2 dan hebben we het einde bereikt
If j = 2 Then
.WaitForString "DETAIL"
Exit Do
End If
Loop
End With
fPick_Rep = strData
End Function
Public Sub leesrapport()
Dim varData As Variant
varData = fPick_Rep(Me)
End Sub
Nick
Blijkbaar nog ne alert gevonden in mailbox!
Manmanman... vele scripts in novaveg interageren met excel, er zijn meerdere excel-exports vanuit SAP, het door Univeg geprogrammeerde Usys doet al jaren exports naar excel, ik heb zulke applicaties geschreven met vrijgave van broncode toen ik vertrok... allemaal op dezelfde manier. Ik deed het op advies van IT-Univeg : 'geen gezaag meer over layout, ze moeten hun plan maar trekken met grafiekskes en pivotjes'.
De kennis is er (wel niet in Novaveg). De wil en het mogen... hehe... je 'vriend' Erwin beslist daarover lol.
Zoals beloofd zal ik me daarover eens laten horen. Ben zelfs bijna zeker dat ik er ga tegenkomen volgende maand in Antwerp expo.
Hello everybody,
I'm trying to read out text information out of a reflection session.
The lines are stored in strData and I can see all the textlines in the Locals window.
There is however a problem I can't solve no mather how hard I try.
My programming skills are these from a beginner.
After the textstrings are stored in the variable strData I would like to copy them into an Excel sheet.
If all the textlines are copy-d then I would like to send that sheet with an Email to a group of people. All this by using VBA
Can anybody help me please
Here's is an example of the code I've already have(It was ever written by someone else):
'Inlezen rapport SPRRA
'Sessie : Reflection Newbase sessie,cursor staat op het in te lezen rapport in het SPRRA scherm
'Resultaat : 1 dimensionele array van de lijnen van het betreffende rapport
Private Function fPick_Rep(Sessie As Reflection4.Session) As Variant
Dim strData() As String, i As Integer, j As Integer, r As Integer, l As Long, t As Long, s As Long
ReDim strData(0 To 0)
With Sessie
Dim strWacht(1 To 2) As String
strWacht(1) = VBA.Chr(VBA.Asc(vbLf)) + ":" 'vbLf is een linefeed
strWacht(2) = VBA.Chr(VBA.Asc(vbLf)) + "(EOF):"
Sessie.DisplayMemoryBlocks = 10 'geheugen wordt hier vergroot
Sessie.DisplayMemoryBlocks = 9 'hier terug verlaagd
.Transmit "b"
Do
j = Sessie.Application.WaitForStrings(strWacht, 5)
If j = 0 Then
MsgBox "Er liep iets mis !"
Exit Function
Else
r = .cursorRow 'kijkt waar de cursor staat en stopt dit in var.r
l = UBound(strData) 'om de bovenkant van de file aan te geven
s = 0
ReDim Preserve strData(0 To l + r - VBA.IIf(l = 0, 1, 0) + VBA.Abs(Sessie.DisplayMemoryTopRow))
t = VBA.IIf(l = 0, 0, 1)
For i = Sessie.DisplayMemoryTopRow To r - 1
strData(l + s + t) = .GetText(i, 0, i, .DisplayColumns)
s = s + 1
Next
End If
'Even schermhegeheugen resetten
Sessie.DisplayMemoryBlocks = 10
Sessie.DisplayMemoryBlocks = 9
.Transmit VBA.Chr(13) 'character 13 is een carriage return
DoEvents
'Als j = 2 dan hebben we het einde bereikt
If j = 2 Then
.WaitForString "DETAIL"
Exit Do
End If
Loop
End With
fPick_Rep = strData
End Function
Public Sub leesrapport()
Dim varData As Variant
varData = fPick_Rep(Me)
End Sub
Nick
'Inlezen rapport SPRRA
'Sessie : Reflection Newbase sessie,cursor staat op het in te lezen rapport in het SPRRA scherm
'Resultaat : 1 dimensionele array van de lijnen van het betreffende rapport
Private Function fPick_Rep(Sessie As Reflection4.Session) As Variant
Dim strData() As String, i As Integer, j As Integer, r As Integer, l As Long, t As Long, s As Long
ReDim strData(0 To 0)
With Sessie
Dim strWacht(1 To 2) As String
strWacht(1) = VBA.Chr(VBA.Asc(vbLf)) + ":" 'vbLf is een linefeed
strWacht(2) = VBA.Chr(VBA.Asc(vbLf)) + "(EOF):"
Sessie.DisplayMemoryBlocks = 10 'geheugen wordt hier vergroot
Sessie.DisplayMemoryBlocks = 9 'hier terug verlaagd
.Transmit "b"
Do
j = Sessie.Application.WaitForStrings(strWacht, 5)
If j = 0 Then
MsgBox "Er liep iets mis !"
Exit Function
Else
r = .cursorRow 'kijkt waar de cursor staat en stopt dit in var.r
l = UBound(strData) 'om de bovenkant van de file aan te geven
s = 0
ReDim Preserve strData(0 To l + r - VBA.IIf(l = 0, 1, 0) + VBA.Abs(Sessie.DisplayMemoryTopRow))
t = VBA.IIf(l = 0, 0, 1)
For i = Sessie.DisplayMemoryTopRow To r - 1
strData(l + s + t) = .GetText(i, 0, i, .DisplayColumns)
s = s + 1
Next
End If
'Even schermhegeheugen resetten
Sessie.DisplayMemoryBlocks = 10
Sessie.DisplayMemoryBlocks = 9
.Transmit VBA.Chr(13) 'character 13 is een carriage return
DoEvents
'Als j = 2 dan hebben we het einde bereikt
If j = 2 Then
.WaitForString "DETAIL"
Exit Do
End If
Loop
End With
fPick_Rep = strData
End Function
Public Sub leesrapport()
Dim varData As Variant
varData = fPick_Rep(Me)
End Sub