Hi Experts,

i want a macro which can copy data from another application to excel.

below is the code which i am trying to use. i dont have any workbook to 
explain this example. just a simple logic copy data from other application 
and paste in to excel then again switch to that application then paste data 
in to the excel after the first row. (row by row copy paste macro)

Option Explicit
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As 
Integer()
 

Const VK_F6 = &H75
Const VK_ESC = &H1B
 Const VK_CONTROL = &H11 ' COntrol
 Const VK_C = &H43 ' c

 Const VK_TAB = &H9 ' Tab
Const VK_MENU = &H12 'menu
Const VK_V = &H56 ' v key



 
Sub Scannings()
    Dim lngRow As Long, str As String
 
    lngRow = Selection.Row
    str = Cells(lngRow, 1) & vbTab & Cells(lngRow, 2) & vbTab & _
            Format(Cells(lngRow, 3), "dd - mmm - yyyy")
 
    MsgBox "Click OK, then click the First Name box on the external 
application, then press F6 on the keyboard"
    WaitAndSend str, VK_F6, VK_ESC
    WaitAndSend VK_MENU, VK_TAB
    WaitAndSend VK_CONTROL, VK_C
    WaitAndSend VK_MENU, VK_TAB
    WaitAndSend str, VK_CONTROL, VK_V
End Sub
 
Sub WaitAndSend(SendString As String, ExecuteKey As Long, CancelKey As Long)
    Do
        DoEvents
        If GetAsyncKeyState(CancelKey) <> 0 Then Exit Do
        If GetAsyncKeyState(ExecuteKey) <> 0 Then
            SendKeys SendString, True
            Exit Do
        End If
    Loop
End Sub

Please help me everyday i am spending 5-6 hrs to do this job (alt + tab, 
copy one row, paste in to excel, again alt tab, copy second row, alt tab, 
paste in to excel row by row)


Thanks in Advanced.

Regards,
Avinash

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to