Sendkeys Add-In Problem
Okay, so I have the following code to automate routine data entry around here and it was working:
Sub CellToTURNS()
'Select the first cell
ActiveWorkbook.ActiveSheet.Range("A1").Select
'Check to see if order is pasted correctly
CellContents = ActiveCell.Value
If CellContents = "" Then
MsgBox "Paste an order into the worksheet."
Exit Sub
End If
'Activate TURNS if it isn't already
Appname = "TURNS"
AppFile = "F:\Program Files\FacetCorp\FacetWin\fwt.exe"
On Error Resume Next
AppActivate (Appname)
If Err <> 0 Then
Err = 0
TaskID = Shell(AppFile, 1)
If Err <> 0 Then MsgBox "Can't start " & AppFile
End If
Pause 1 'wait for TURNS to activate
'Loop Thru the Spreadsheet, pasting the order
i = 1
Do While CellContents <> ""
CellContents = Range("A" & i)
Application.SendKeys CellContents & "~", True
CellContents = Range("B" & i)
If CellContents = "0" Then Application.SendKeys "~~~~~", True Else _
Application.SendKeys CellContents & "~~~~~", True
i = i + 1
Loop
End Sub
Problem is, now I have saved it as an add-in and it doesn't work anymore. Instead of switching to the "TURNS" application and doing the sendkeys there, it is sending the keystrokes to the current worksheet and creating a new worksheet with the name "turns"... Does anyone know why this is? This code was functioning fine until I turned it into an add in...
Thanks
|