Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2006, 01:31 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid printing "1" after Sendkeys font45 Excel VBA 2 August 18th, 2006 05:21 PM
SendKeys wassa Access VBA 1 July 16th, 2006 02:55 AM
Please Help! - SendKeys wassa Access VBA 1 June 9th, 2006 07:41 AM
Problem with SendKeys while downloading a file desperado1306 Excel VBA 0 May 25th, 2006 12:05 PM
SendKeys.Send LCTRL ? ItshiBan VS.NET 2002/2003 0 September 4th, 2003 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.