blue_fields wrote: ↑05 May 2023, 10:37
@wetware05 thank you! Your solution may work, I'm gonna do some tests today or tomorrow. However, so far I am able to restart my computer and the "CompanyLetter.Clip" file does successfully paste properly when I load it into the clip board, perhaps because it's copied from a fixed word doc on my system?
@RussF My apologies, in trying to keep my post simple I think I just made it more confusing in some ways. I am aware of mail merge in word and it would solve what I'm technically trying to do, but the issue is that it's too slow. I will explain what I'm trying to do properly this time:
Basically, I work in a student records department that has a lot of outdated manual processes. For example, if faculty wants to change a grade of a student, or a student wants to change their program, in both these cases they are required to fill out a form, get it signed, and then email it to my department. So just to keep it simple with these two examples, I may be responding with either 1. "Grade Change Processed Reply Letter Template" or 2. "Program Change Processed Reply Letter Template" depending on what is requested of me via email. I might do 50 of these in a day, which means I have to open up the word document of the 1. or 2. template letter, copy its contents, paste it into my email reply box, and then manually enter the student's name in the name field of the template, same with ID, course name, etc.
Now in reality I have ~20 different processes like this. So it's pretty slow to individually open up a separate word doc for each, manually copy and paste it into the email. It would be much faster to simply have a letter template saved as a clipboard object, and I simply have a hotkey or custom keyboard shortcut to paste the template I need instantly into the email response. No opening up word, no highlighting, etc.
So I can already do this, but I want to take it a step further. When I get an email for a grade change for example, I need to type the student id, course name, term, etc. into our system, so my idea was to have a GUI with some edit fields, in which I would type in that info. When I get to emailing back with the reply, the AHK script would look at what info is in my GUI edit fields, and then sub in the appropriate info for the current template I am pasting (student ID, name, course, etc). Hopefully it's clearer now what I'm trying to achieve.
What you want is very doable and well suited for AHK but I would forget the binary clipboard approach and look into COM.
Here is an example of creating an Outlook email and then pasting a Word document into the email.
Code: Select all
; Copy Whole Story from Word
WordTemplateFile := A_Desktop '\Test\TestDoc.docx'
wdApp := ComObject("Word.Application")
wdDoc := wdApp.Documents.Open(WordTemplateFile)
wdApp.Selection.WholeStory
wdApp.Selection.Copy
wdApp.Selection.End := true
wdDoc.Close()
wdApp.Quit()
; Create Email and Paste Clipboard to Email Body
olApp := ComObjActive("Outlook.Application")
olMailItem := olApp.CreateItem(0) ; 0 = Mail Item
wdDoc := olMailItem.GetInspector.WordEditor
wdDoc.Range(0,0).Paste
olMailItem.Display
Outlook must be open. This opens and closes Word each time for demonstration but if Word was just left open it would be much faster for a batch process.
Once the email is created, then you can change text items as you might need with some Find and Replace. Like Find <<<NAME>>> and replace with the actual name. The editor used in Outlook is actually a plugin of Word.
If you don't really need all the fancy formatting that Word can allow, I would not even bother with Word templates. I mean if you are doing a bunch of pictures and colored text of all different sizes and really graphically pleasing formatting, then Word templates are great but if you are just needing text then Word is overkill.
Also, AHK can pull information from Excel very easily. If you already had the information in Excel, AHK could easily pull the information and create 50 emails and send them with the push of one button.
But if you got to type it in anyways, you could create a Gui that enters the data in your system and also sends the email at the same time, after you enter each. Or enter it in your system and then have AHK pull the information from your system by some means.
There are lots of options but this sounds like a great chance to lessen your workload dramatically depending on your scripting skills.
Rereading your post, since the original request forms are emailed to you, AHK could probably pull a lot of the information automatically from the emails, even if it is scanned images of the forms.
AHK watches for emails, pull data from appropriate emails, puts the data in an Excel spreadsheet, user reviews the data for problems, click a button, email sent. Pulling the data from a scanned form would be the hard part, sending the emails is relatively easy. AHK could also enter the data from the Excel in your system but that can be tricky too depending on your system.
It just occurred to me that you may not use Outlook but some online email application. Office is kind of the standard for business but not so much for education. That makes things quite a bit more complicated and the dream of full automation fleeting.
Ah, well, at least this shows you how to put a Word document on the clipboard without saving it as a binary.
FG