Sorry, I did not clearly explain the result. I want it to be included in each line of the generated result.
Sub Generate_Code()
Dim WS As Worksheet
Dim I As Long
Dim LastRow As Long
Dim FF As Integer
Dim Temp$, Temp$2, Temp$3
Set WS = ActiveSheet
FF = FreeFile
Open ActiveWorkbook.Path & "\" & ActiveWorkbook.NAME & ".mac" For Output As #FF
Print #FF, "[PCOMM SCRIPT HEADER]"
Print #FF, "LANGUAGE=VBSCRIPT"
Print #FF, "DESCRIPTION="
Print #FF, "[PCOMM SCRIPT SOURCE]"
Print #FF, "OPTION EXPLICIT"
Print #FF, "autECLSession.SetConnectionByName" & Chr(40) & "ThisSessionName" & Chr(41)
Print #FF, ""
Print #FF, "REM This line calls the macro subroutine"
Print #FF, "subSub1_"
Print #FF, ""
Print #FF, "sub subSub1_" & Chr(40) & Chr(41)
Print #FF, ""
Print #FF, ""
With WS
For I = 5 To .Range("A" & .Rows.Count).End(3)(1).Row
LCol = .Cells(I, .Columns.Count).End(xlToLeft).Column
Temp2$ = ""
If LCol > 1 Then
For J = 2 To .Cells(I, .Columns.Count).End(xlToLeft).Column
Temp2$ = Temp2$ & .Cells(I, J)
Next
End If
Temp$ = Left(.Range("A" & I) & "_________", 9)
Print #FF, " autECLSession.autECLPS.SendKeys " & Chr(34) & Temp$ & Chr(34) & ", 23,47"
Print #FF, " autECLSession.autECLPS.SendKeys " & Chr(34) & "[enter]" & Temp2$ & Chr(34)
Print #FF, " autECLSession.autECLPS.SendKeys " & Chr(34) & "[printps]" & Temp3$ & Chr(34)
Print #FF, " autECLSession.autECLPS.Wait 700"
Next I
End With
Print #FF, ""
Print #FF, "end sub "
Print #FF, ""
Close #FF
End Sub
But the Temp3$, I want to associate it to the cell B2.
So I can add Temp4$ to B3, and so on..
Thanks.
Bookmarks