I have an Access 2003 database that I have used the built-in VBA SendKeys function, as well as an API MySendKeys replacement programmed by Dev Ashish for sending keystrokes to an external application for filling in a form on the application. The application I am sending the data to is Creative Media Source Player. The Access database sends the file name, "artist name", title, genre, and maybe one other piece of info that I can't remember at the moment.
At first, it worked 100% fine with just using the SendKeys function. Then we upgraded the computer from a Single core (500mhz) processor computer to a Dell with dual core Pentium D processor. All of a sudden, I had all kinds of problems with the SendKeys function not working correctly. So, I found Dev Ashish's MySendKeys API call after doing some research into using API calls. After some tweaking of how I used it, it worked flawlessly.
Then, I ran some Windows updates and possible Office udpates on the machine. Since that time, the MySendKeys has been having some of the same problems as SendKeys. It would fill in one field correctly, and no other fields; or either put the title in the file name; or do something along those lines.
So, I thought I'd do some more searching, to see if there were another solution. I read about an API call, "SendMessage". It sounded like it could solve my problems, but I wasn't sure how to use it in VBA. So, I kept searching. Then I found the site, which seems to be a good resource for API calls in VB/VBA.
Here is my problem: I tried one of their samples, to see how this works, and I'm getting an error that I've not the slighest of where to go with it. I searched the help file, and tried searching the web, but just didn't find what I think is a real answer.
All of the code works, except for one line, and it breaks, b/c of one reference to a handle property. My immediate guess is that a listbox doesn't have a handle. But, I'll post it here, so that anyone else can look at it, and possibly give me some advice/direction on it:
The code from the example:
The error message:
At first, it worked 100% fine with just using the SendKeys function. Then we upgraded the computer from a Single core (500mhz) processor computer to a Dell with dual core Pentium D processor. All of a sudden, I had all kinds of problems with the SendKeys function not working correctly. So, I found Dev Ashish's MySendKeys API call after doing some research into using API calls. After some tweaking of how I used it, it worked flawlessly.
Then, I ran some Windows updates and possible Office udpates on the machine. Since that time, the MySendKeys has been having some of the same problems as SendKeys. It would fill in one field correctly, and no other fields; or either put the title in the file name; or do something along those lines.
So, I thought I'd do some more searching, to see if there were another solution. I read about an API call, "SendMessage". It sounded like it could solve my problems, but I wasn't sure how to use it in VBA. So, I kept searching. Then I found the site, which seems to be a good resource for API calls in VB/VBA.
Here is my problem: I tried one of their samples, to see how this works, and I'm getting an error that I've not the slighest of where to go with it. I searched the help file, and tried searching the web, but just didn't find what I think is a real answer.
All of the code works, except for one line, and it breaks, b/c of one reference to a handle property. My immediate guess is that a listbox doesn't have a handle. But, I'll post it here, so that anyone else can look at it, and possibly give me some advice/direction on it:
The code from the example:
Code:
'This project needs a ListBox, named List1 and a TextBox, named Text1
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Private Sub Form_Load()
'KPD-Team 1998
'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
'E-Mail: KPDTeam@Allapi.net
'Add some items to the listbox
With List1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
End Sub
Private Sub Text1_Change()
'Retrieve the item's listindex
[highlight]List1.ListIndex = SendMessage(List1.[b]hwnd[/b], LB_FINDSTRING, -1, _
ByVal CStr(Text1.Text))[/highlight]
End Sub
The error message:
Compile error:
Method or data member not found