Hello
I've recently been trying to create a piece of code within XL VBA to automatically pre-fill a user form with specific information, to do this I have used the keybd_event API to send virtual key commands to the form, it works except it misses a field of information out but does the other fields.
I have made a mock up of what the xl document I am making is and a replica of the xl sheet, which is in the form of an attachment.
Once you've opened up both documents press the proceed button and you'll end up with the form like so...
If your wondering why I'm doing it this way or have an queries I have listed a few Q and A's below to clear up the most likely questions:
Q. Why are you using keybd_event API to enter another user form when it's in the same program?
A. This is because the user form is saved within an old document with passwords so I can't just access the vba code of the form to interact with it.
Q. Doesn’t that mean your hacking the code?
A. No because anyone can use the user form anyway and type what they want into it, the only difference I'm doing is just speeding up the data input that the user would normally type in anyway.
Q. Why don't you just replicate a similar form and print the documents out that way?
A. The printers the user form uses are old 1970/80's printers which are incredibly difficult to code and don't appear in the printers and faxes folder like normal ones. They are special too so resorting to normal printers isn’t an option.
Q. Why are you referring to column letters with ASCII codes?
A. This was because the sheet you see on the workbook I made will not be selected on the final version so referring to Cells didn’t work when I tried it.
If you can get it to work I would be a happy person and be very greatfull.
Thanks
Chacanger
PS. Code can be seen in my xl worksheet.