Click here to Skip to main content
15,890,438 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSorting Gridview with Data from DataTable error Pin
Commish1314-Nov-13 5:11
professionalCommish1314-Nov-13 5:11 
AnswerRe: Sorting Gridview with Data from DataTable error Pin
Richard MacCutchan14-Nov-13 6:13
mveRichard MacCutchan14-Nov-13 6:13 
GeneralRe: Sorting Gridview with Data from DataTable error Pin
Commish1314-Nov-13 7:07
professionalCommish1314-Nov-13 7:07 
GeneralRe: Sorting Gridview with Data from DataTable error Pin
Richard MacCutchan14-Nov-13 7:16
mveRichard MacCutchan14-Nov-13 7:16 
GeneralRe: Sorting Gridview with Data from DataTable error Pin
Tim Carmichael14-Nov-13 8:47
Tim Carmichael14-Nov-13 8:47 
QuestionTabing to a certain program window from excel... Pin
harry.roy14-Nov-13 4:52
harry.roy14-Nov-13 4:52 
AnswerRe: Tabing to a certain program window from excel... Pin
Richard MacCutchan14-Nov-13 6:16
mveRichard MacCutchan14-Nov-13 6:16 
AnswerRe: Tabing to a certain program window from excel... Pin
TnTinMn14-Nov-13 16:35
TnTinMn14-Nov-13 16:35 
Here is a simplified VBA example that may be of help to you. The big issue is getting a handle to the window into which you want to paste.
VB
' ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx
Private Declare Function FindWindow Lib "user32" _
   Alias "FindWindowA" _
   (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
   
' this is a special case of FindWindow
Private Declare Function FindWindowByCaption Lib "user32" _
   Alias "FindWindowA" _
   (ByVal thismustbezero As Long, _
    ByVal lpWindowName As String) As Long
    
' ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633500%28v=vs.85%29.aspx
Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" _
    (ByVal parentHandle As Long, _
     ByVal childAfter As Long, _
     ByVal lclassName As String, _
     ByVal windowTitle As String) As Long
   
' ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950%28v=vs.85%29.aspx
Private Declare Function SendMessage Lib "user32.dll" _
    Alias "SendMessageA" _
    (ByVal hWnd As Long, _
     ByVal msg As Long, _
     ByVal wParam As Long, _
     ByVal lParam As Long) As Long

' WM_Paste will be sent to the window to tell it to paste from the clipboard
Private Const WM_Paste As Long = &H302

Sub Test()
    ' using notepad just as an example external application
    
    Dim res As Double
    res = Shell("notepad.exe", vbNormalFocus)
    
    ' get the handle to the notepad application window
    Dim hWndNotepad As Long
    hWndNotepad = FindWindowByCaption(0, "Untitled - Notepad")
    
    ' Typically, the window you want to paste to is a child window
    ' to the main window.  In the the case of Notepad, the child window has
    ' the class name "Edit".
    Dim hwndEdit As Long
    hwndEdit = FindWindowEx(hWndNotepad, 0, "Edit", "")
    
    ' copy something to the clipboard
    Range("Sheet1!A1").Formula = "This was copied from my excel spreadsheet"
    Range("Sheet1!A1").Copy
    
    ' now that we have the handle to the notpad edit window,
    ' send it a the WM_Paste message
    Dim res2 As Long
    res2 = SendMessage(hwndEdit, WM_Paste, 0, 0)

End Sub
The Spy++ program included in the full version of Visual Studio is quite helpful for determining the class name of a window.

modified 14-Nov-13 22:48pm.

GeneralRe: Tabing to a certain program window from excel... Pin
harry.roy14-Nov-13 16:43
harry.roy14-Nov-13 16:43 
GeneralRe: Tabing to a certain program window from excel... Pin
TnTinMn14-Nov-13 16:55
TnTinMn14-Nov-13 16:55 
QuestionNeed Help Pin
Member 1040050613-Nov-13 17:44
Member 1040050613-Nov-13 17:44 
AnswerRe: Need Help Pin
Richard MacCutchan13-Nov-13 21:43
mveRichard MacCutchan13-Nov-13 21:43 
AnswerRe: Need Help Pin
Marco Bertschi13-Nov-13 22:17
protectorMarco Bertschi13-Nov-13 22:17 
QuestionConnect MySQL Database in Linux PC by VB.NET Pin
Biplob Singha Shee13-Nov-13 3:16
Biplob Singha Shee13-Nov-13 3:16 
AnswerRe: Connect MySQL Database in Linux PC by VB.NET Pin
Dave Kreskowiak13-Nov-13 4:44
mveDave Kreskowiak13-Nov-13 4:44 
GeneralRe: Connect MySQL Database in Linux PC by VB.NET Pin
Biplob Singha Shee13-Nov-13 8:03
Biplob Singha Shee13-Nov-13 8:03 
AnswerRe: Connect MySQL Database in Linux PC by VB.NET Pin
Bernhard Hiller13-Nov-13 21:05
Bernhard Hiller13-Nov-13 21:05 
Questionvoting system based on image steganography Pin
fizie896-Nov-13 6:38
fizie896-Nov-13 6:38 
AnswerRe: voting system based on image steganography Pin
Richard MacCutchan6-Nov-13 9:06
mveRichard MacCutchan6-Nov-13 9:06 
AnswerRe: voting system based on image steganography Pin
Mycroft Holmes6-Nov-13 12:00
professionalMycroft Holmes6-Nov-13 12:00 
QuestionStill The problem not solved regarding the edit button column. Pin
Member 101928355-Nov-13 20:40
Member 101928355-Nov-13 20:40 
QuestionRe: Still The problem not solved regarding the edit button column. Pin
Richard MacCutchan5-Nov-13 21:40
mveRichard MacCutchan5-Nov-13 21:40 
AnswerRe: Still The problem not solved regarding the edit button column. Pin
Member 101928355-Nov-13 22:11
Member 101928355-Nov-13 22:11 
AnswerRe: Still The problem not solved regarding the edit button column. Pin
Member 101928355-Nov-13 22:17
Member 101928355-Nov-13 22:17 
GeneralRe: Still The problem not solved regarding the edit button column. Pin
Mycroft Holmes5-Nov-13 23:40
professionalMycroft Holmes5-Nov-13 23:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.