Moving data from one program to another by VBA (1 Viewer)

Shas91

Member
Local time
Today, 15:19
Joined
Nov 26, 2019
Messages
41
Hi !

I have now started to fin a sollution to move data from access to a non windows program and I need some help... Here is the code...


Private Sub Kommandoknapp537_Click()
Dim XKordinat, YKordinat As String

'CopyToClip (txtCoustumerNr) '1. This copy the textfield from Access to the clipboard and it works fine

XKordinat = "192" '2. This is the cordinates for the textfields in a other program
YKordinat = "199"

SetCursorPos XKordinat, YKordinat
mouse_event MusKlick_VänsterNer, 0&, 0&, 0&, 0& 'Left click down
mouse_event MusKlick_VänsterUpp, 0&, 0&, 0&, 0& 'release left click '3. This code is moving the cursor to the textfield in the other program.


SendKeys "%{TAB}", True ' 4. This comand makes the other program active, So far so god... We have the textfield in the other program highlited and
' the cursor blinking


'Now I'm stucked. I cant get the code to paste the value. If I manually press ctrl+V it paste the value as it should

DoCmd.RunCommand acCmdPaste
End Sub

Problebly very easy so I need some help

Sincerly Shas
 

plog

Banishment Pending
Local time
Today, 17:19
Joined
May 11, 2011
Messages
11,646
Use SendKeys to do the pasting (Ctrl + V)

However, I can't imagine 192,199 will always be the coordinates of the input field that you want to hit.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:19
Joined
Feb 28, 2001
Messages
27,188
The clip you showed us has an apostrophe in front of the CopyToClip, which makes it a comment - so it doesn't copy anything to the clipboard. Not sure WHAT you are getting with manual methods, but acCmdPaste won't work if the clipboard is empty at the time.
 

Shas91

Member
Local time
Today, 15:19
Joined
Nov 26, 2019
Messages
41
The clip you showed us has an apostrophe in front of the CopyToClip, which makes it a comment - so it doesn't copy anything to the clipboard. Not sure WHAT you are getting with manual methods, but acCmdPaste won't work if the clipboard is empty at the time.

CopytoClip is a subroutin that copy to the clipboard I translate it to english to better describe the problem... it it has nothing to do with the issue...
 
Last edited:

Shas91

Member
Local time
Today, 15:19
Joined
Nov 26, 2019
Messages
41
Use SendKeys to do the pasting (Ctrl + V)

However, I can't imagine 192,199 will always be the coordinates of the input field that you want to hit.

I have tried SendKeys "^c", True that but it wont work... About the cordinates You have ofcourse right.. In my case I'm solving this by a question "Click on the upper left corner followed by Click on the lower right corner" by this information I can calculate were the fields are..
 

Shas91

Member
Local time
Today, 15:19
Joined
Nov 26, 2019
Messages
41
I guess I found out what the problem is...

If I step throw the program by pressing F8 it works fine until after command

SendKeys "%{TAB}", True

This piece of code switch program and after that nothing happends.... I'll guess it never execute

SendKeys "^v", True

Atleast nothing happends if You press F8
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 23:19
Joined
Feb 19, 2013
Messages
16,616
suspect if you have moved the focus to a non windows program then the code is still running, but in windows.

what is this other non windows program?
 

Shas91

Member
Local time
Today, 15:19
Joined
Nov 26, 2019
Messages
41
Yepp.. its a buissness program för economy called Softone

I'm not very god at this but I'm thinking of doing a batfil that execute the command and after that returns to Access... But how ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:19
Joined
May 7, 2009
Messages
19,245
i think it would be best to just use IBM to input those text.
 

Users who are viewing this thread

Top Bottom