Results 1 to 3 of 3

Thread: Sending contents of variables to other apps

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Location
    Georgia, USA
    Posts
    3

    Sending contents of variables to other apps

    I use Access for dbm, I need to select records from there and send the contents to a non windows app that doesnt support "paste". Can you use "sendkeys" to do this by replacing the string with the variable name? or is there another way to do this?

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    The short answer is that yes, it can be done. However it is an extremely difficult task. One main problem is that the code runs faster than the action can take place in the remote screen, so we have to put in lots of Wait lines to give a couple of seconds each time for this to happen. This is made more difficult if using a server, when the speed varies depending on the current amount of users. In the end you never get something that works 100% all the time. That said, despite the running problems, users would rather have it than not. I suggest you do some small trials.

    I do not recommend using this method to send data to an external application unless you are able to check that the data actually gets there. Better used to read data.

    Sendkeys
    Look up Shell and SendKeys in VB Editor help and run the examples.

    API Calls
    There are occasions when sendKeys does not work all the time. We then get into the realm of API calls. These work well, but the problem is that it is not possible to step through our code to debug - because the code window is then the active one, and our text ends up there ! Here is part of my code which declarea the API functions used. I suggest you do a Google search and try some out on their own to get an idea of what they do before attempting to write any code of your own.


    Code:
    '---------------------------------------------------------
    Declare Function FindWindow Lib "user32.dll" _
        Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
    '-
    Public Declare Function BringWindowToTop Lib "user32.dll" (ByVal hwnd As Long) As Long
    '-
    Declare Function M_GetActiveWindow Lib "user32" _
        Alias "GetActiveWindow" () As Long
    '-
    Private Declare Function SetCursorPos Lib "user32" _
        (ByVal x As Long, ByVal y As Long) As Long
    '-
    Private Declare Function GetWindowRect Lib "user32" _
        (ByVal xHwnd As Long, lpRect As RECT) As Long
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    '-
    Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal _
    bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    '-
    Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, _
        ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, _
        ByVal dwExtraInfo As Long)
    '---------------------------------------------------------------------------
    Regards
    BrianB
    -------------------------------

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2004
    Location
    Georgia, USA
    Posts
    3
    Ok now I'm gettin stupid in my old age. I cant remember how to get the sub to loop through the table to EOF. Any ideas? heres what I have...

    Dim SerTable As Object
    Dim SerNum As String
    Set SerTable = Application.CurrentDb.OpenRecordset("Serial")
    Shell ("C:\Program Files\Microsoft Office\Office\WinWord.exe")
    While Not SerTable.EOF
    SerNum = SerTable.Fields("Serial").Value
    SendKeys SerNum
    SendKeys "~"
    SerTable.MoveNext
    Wend


    Of course this doesnt work, It opens Word but then sends then values to the module window.
    Last edited by ArUllamh; May 20th, 2004 at 09:35 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width