MS Office Forum / Word / Programming / February 2008
Stuffing autocorrect entries separated by tabs into clipboard in Word 2003
|
|
Thread rating:  |
Alan - 04 Feb 2008 08:19 GMT Here's what I want to do: I am working in Word 2003, transcribing medical dictation. I receive a document into which I transcribe the dictation. There are several data in the supplied demographic sheet: A medical record number, a first name, and a last name. Thanks to help from this group, I constructed a macro that creates an autocorrect entry for each of these data.
I want to create a macro that will put these three data, separated by tabs, into the clipboard buffer. That way, I can switch to a spreadsheet and paste these three data into three adjacent cells and switch back to Word.
I could just type them out onto the page, highlight, and block them and maybe even figure out a way to record such a process as a macro. But is there a way to do this on-the-fly without having to type the data, or even have a macro type the data, into the document?
Graham Mayor - 04 Feb 2008 09:00 GMT How do the three items appear in the document? Can you display an example?
 Signature <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP
My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Here's what I want to do: > I am working in Word 2003, transcribing medical dictation. I receive a [quoted text clipped - 11 lines] > But is there a way to do this on-the-fly without having to type the > data, or even have a macro type the data, into the document? Alan - 04 Feb 2008 09:53 GMT The document is divided into a header, a text area, and a footer with a page break. I am able to get the three items into three separate autocorrect entries. That way, instead of having to type out the patient's name half a dozen times, I can use the autocorrect entry so that typing UU (for first name) and PP (for last name) expands out into Ignatze Kadiddlehopper-VonStuppen (sorry, but it's late and I'm tired).
Anyhow, I've already got the macro written that creates an autocorrect entry for the medical record number (MRN), first name (UU), and last name (PP). These have been very useful over the past several days.
But I also enter these data into a spreadsheet. One way of quickly doing that is to type out the following on a separate line: MRN <then tab> PP <then tab>UU <then tab> This results in 999988.....Kadiddlehopper-VonStuppen......Ignatz (where the spaces between these are actually tabs).
Then I can highlight these, hit <alt><x> to cut to the clipboard, hit <alt><shift> to switch to the spreadsheet, place the cursor into the medical record cell, and hit <ctrl><v>, which pastes the whole shmeer into three adjacent cells.
What I hope to be able to do is to write a macro that will look into the silicone memory banks, find MRN, PP, UU, and then stuff the values into which they expand into the clipboard, separated of course by tabs.
Is that possible?
Regards,
Alan
> How do the three items appear in the document? > Can you display an example? [quoted text clipped - 14 lines] >> But is there a way to do this on-the-fly without having to type the >> data, or even have a macro type the data, into the document? Doug Robbins - Word MVP - 04 Feb 2008 10:20 GMT I think that you should really be doing something more like that covered in the last of these articles:
Please Fill Out This Form Part 1: Create professional looking forms in Word http://www.computorcompanion.com/LPMArticle.asp?ID=22
Part 2: Adding Automation to your Word forms. http://www.computorcompanion.com/LPMArticle.asp?ID=46
Part 3: Learn more VBA (macros) to automate your forms. http://www.computorcompanion.com/LPMArticle.asp?ID=119
Part 4: Use custom dialog boxes in your Word forms http://www.computorcompanion.com/LPMArticle.asp?ID=127
Part 5: Connect your AutoForm to a database to save input time and keep better records! http://www.computorcompanion.com/LPMArticle.asp?ID=136
 Signature Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
> The document is divided into a header, a text area, and a footer with a > page break. I am able to get the three items into three separate [quoted text clipped - 47 lines] >>> But is there a way to do this on-the-fly without having to type the >>> data, or even have a macro type the data, into the document? Alan - 04 Feb 2008 10:30 GMT Thanks for the input, Doug.
Those are interesting but not what I need.
I have to work in a very narrowly-defined set of parameters that are set for me. What I need to be able to do is figure out how I can stuff three autocorrect expansions, separated by tabs, into the clipboard. I can do it using an AutoHotKey script, but I would rather have a VBA macro that does it.
So forms are not what I need. What I need is to be able to cause the clipboard to be filled with three autocorrect expansions separated by two tabs.
Regards,
Alan
>I think that you should really be doing something more like that covered in >the last of these articles: [quoted text clipped - 67 lines] >>>> But is there a way to do this on-the-fly without having to type the >>>> data, or even have a macro type the data, into the document? Summer - 04 Feb 2008 10:22 GMT Do you know that Autocorrect is also in Excel which I am assuming is your spreadsheet - so you already have your expansion available (I use some 1850 entries) Does that help!
> The document is divided into a header, a text area, and a footer with a > page break. I am able to get the three items into three separate [quoted text clipped - 47 lines] >>> But is there a way to do this on-the-fly without having to type the >>> data, or even have a macro type the data, into the document? Alan - 04 Feb 2008 11:07 GMT Hi Summer,
With all due respect, that's not what I need. This is what I need, bearing in mind that I don't know very much about VBA
Dim aTmp as string Dim bTmp as string Dim cTmp as string aTmp:=Autocorrect(UU) 'assign contents of autocorrect entry UU to aTmp (patient's last name) bTmp:=Autocorrect(PP) 'assign contents of autocorrect entry PP to bTmp (patient's first name) cTmp:+Autocorrect(MRN 'assign contents of autocorrect entry MRN to CTmp (medical record number) clipboard:=aTmp + CHR(9) bTmp + CHR(9) + cTmp 'concatonate the patient's last name, tab, pt first name, tab, MRN into keyboard
That's what I need to be able to do. I assume VBA can do it. But how?
Regards,
Alan
> Do you know that Autocorrect is also in Excel which I am assuming is your > spreadsheet - so you already have your expansion available (I use some [quoted text clipped - 51 lines] >>>> But is there a way to do this on-the-fly without having to type the >>>> data, or even have a macro type the data, into the document? Summer - 04 Feb 2008 12:06 GMT Due respect also what you propose will not work.
> Hi Summer, > [quoted text clipped - 74 lines] >>>>> But is there a way to do this on-the-fly without having to type the >>>>> data, or even have a macro type the data, into the document? Tony Jollans - 04 Feb 2008 13:38 GMT I'm not entirely clear what you are trying to achieve or whether this is the best way of going about it, but this should be the syntax to do what you ask ..
Dim aTmp as string Dim bTmp as string Dim cTmp as string aTmp = Application.AutoCorrect.Entries("UU").Value bTmp = Application.AutoCorrect.Entries("PP").Value cTmp = Application.AutoCorrect.Entries("MRN").Value With New DataObject .SetText aTmp & vbtab & bTmp & cTmp, 1 .PutInClipboard End With
You will need a reference to the "Microsoft Forms 2.0 Object Library" - the easiest way might be just to add a blank userform to the project and it automatically be set.
 Signature Enjoy, Tony
> Due respect also what you propose will not work. > [quoted text clipped - 78 lines] >>>>>> But is there a way to do this on-the-fly without having to type the >>>>>> data, or even have a macro type the data, into the document? Summer - 04 Feb 2008 13:47 GMT Very nice!
> I'm not entirely clear what you are trying to achieve or whether this is > the best way of going about it, but this should be the syntax to do what [quoted text clipped - 99 lines] >>>>>>> But is there a way to do this on-the-fly without having to type the >>>>>>> data, or even have a macro type the data, into the document? Summer - 04 Feb 2008 13:50 GMT Tony, I get an error:
User defined type not defined at NewDataObject
how do I fix that?
> I'm not entirely clear what you are trying to achieve or whether this is > the best way of going about it, but this should be the syntax to do what [quoted text clipped - 99 lines] >>>>>>> But is there a way to do this on-the-fly without having to type the >>>>>>> data, or even have a macro type the data, into the document? Summer - 04 Feb 2008 13:53 GMT Reference - fixed but does not play autocorrect?
> Tony, I get an error: > [quoted text clipped - 108 lines] >>>>>>>> But is there a way to do this on-the-fly without having to type the >>>>>>>> data, or even have a macro type the data, into the document? Tony Jollans - 04 Feb 2008 14:02 GMT What do you mean by 'play'? All it does it put it in the clipboard for manual pasting.
 Signature Enjoy, Tony
> Reference - fixed but does not play autocorrect? > [quoted text clipped - 112 lines] >>>>>>>>> the >>>>>>>>> data, or even have a macro type the data, into the document? Summer - 04 Feb 2008 14:06 GMT Yes, I see that now Tony (it's late). Mine pales in comparison (but I learned a lot) thank you!
> What do you mean by 'play'? All it does it put it in the clipboard for > manual pasting. [quoted text clipped - 116 lines] >>>>>>>>>> the >>>>>>>>>> data, or even have a macro type the data, into the document? Alan - 04 Feb 2008 20:39 GMT Hi Tony,
You do get the picture of what I am trying to do. Thanks for your attempt.
I, however, am also getting a compile-time error message that says: Compile Error. user tefined type not defined.
Unfortunately, I have no idea what to do to remedy that.
Regards,
Alan
> I'm not entirely clear what you are trying to achieve or whether this is > the best way of going about it, but this should be the syntax to do what [quoted text clipped - 99 lines] >>>>>>> But is there a way to do this on-the-fly without having to type the >>>>>>> data, or even have a macro type the data, into the document? Jay Freedman - 04 Feb 2008 21:09 GMT The cause of the "user-defined type" error is the failure to set a reference to the Forms 2.0 library. To repeat the significant part of Tony's post:
>> You will need a reference to the "Microsoft Forms 2.0 Object >> Library" - the easiest way might be just to add a blank userform to >> the project and it automatically be set. The alternative way is to go into Tools > References (the Tools menu in the VBA editor, not in the Word window) and put a check next to "Microsoft Forms 2.0 Object Library" in the list.
 Signature Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
> Hi Tony, > [quoted text clipped - 124 lines] >>>>>>>> having to type the data, or even have a macro type the data, >>>>>>>> into the document? Alan Stancliff - 04 Feb 2008 23:29 GMT Hi Jay,
I hope this gets posted. I tried to set up OE as a newsreader, but this is my work computer, and I'm barred from that. So I downloaded portable Thunderbird and am running it on a USB stick.
Anyhow, it appears at this point that I'm scuppered. When I looked at the TOOLS>REFERENCES menu, I did not see anything called FORMS or MICROSOFT FORMS library. And I'm sure I was in the VBA editor. Perhaps it has a different name. I'll try to see if I can add a "blank userform" to "the project" as soon as I figure out how to do that.
I really appreciate your help as I am pretty much a beginner at VBA. I am an immigrant from the WordPerfect nation, and although I was fairly good at macro command language in WordPerfect, this is pretty different.
Regards,
Alan Stancliff
> The cause of the "user-defined type" error is the failure to set a reference > to the Forms 2.0 library. To repeat the significant part of Tony's post: [quoted text clipped - 6 lines] > VBA editor, not in the Word window) and put a check next to "Microsoft Forms > 2.0 Object Library" in the list. Alan Stancliff - 04 Feb 2008 23:38 GMT Well, I'm chuffed!
I created a dummy form in the project, and now it works like a charm. Many thanks to you and Tony. I appreciate all your help.
Regards,
Alan Stancliff
> The cause of the "user-defined type" error is the failure to set a reference > to the Forms 2.0 library. To repeat the significant part of Tony's post: [quoted text clipped - 6 lines] > VBA editor, not in the Word window) and put a check next to "Microsoft Forms > 2.0 Object Library" in the list. Alan Stancliff - 04 Feb 2008 23:40 GMT Well, I'm chuffed!
I created a dummy form in the project, and now it works like a charm. Many thanks to you and Tony. I appreciate all your help.
Regards,
Alan Stancliff
> The cause of the "user-defined type" error is the failure to set a reference > to the Forms 2.0 library. To repeat the significant part of Tony's post: [quoted text clipped - 6 lines] > VBA editor, not in the Word window) and put a check next to "Microsoft Forms > 2.0 Object Library" in the list. Alan Stancliff - 04 Feb 2008 23:41 GMT Well, I'm chuffed!
I created a dummy form in the project, and now it works like a charm. Many thanks to you and Tony. I appreciate all your help.
Regards,
Alan Stancliff
> The cause of the "user-defined type" error is the failure to set a reference > to the Forms 2.0 library. To repeat the significant part of Tony's post: [quoted text clipped - 6 lines] > VBA editor, not in the Word window) and put a check next to "Microsoft Forms > 2.0 Object Library" in the list. Summer - 04 Feb 2008 13:39 GMT Without going into reasons - and I am sure someone will be able to improve on this macro (with due respect) but it does do what you asked for except using autotext entries.
Using Autotext Entries currently saved in Normal.dot (or any template you choose and name in macro), just resave your autocorrect entries as autotext assigned to same template which you name in macro. The speed is identical to autocorrect with due respect.
Press F3 to play (insert) a named autotext entry when typing. You also have option to have richtext with autotext.
Autotext entries are named for this test macro:
z1 LastName
z2 FirstName
z3 MRN
Option Explicit
Sub GlobalAT1()
Dim aTemplate As Template
Dim myTemplate As Template
For Each aTemplate In Templates
If aTemplate = "Normal.dot" Then
Set myTemplate = aTemplate
myTemplate.AutoTextEntries("z1"). _
Insert Where:=Selection.Range, RichText:=True
Selection.TypeText Text:=vbTab
myTemplate.AutoTextEntries("z2"). _
Insert Where:=Selection.Range, RichText:=True
Selection.TypeText Text:=vbTab
myTemplate.AutoTextEntries("z3"). _
Insert Where:=Selection.Range, RichText:=True
Exit For
End If
Next
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
End Sub
Summer
www.docsliveonline.com
> Due respect also what you propose will not work. > [quoted text clipped - 78 lines] >>>>>> But is there a way to do this on-the-fly without having to type the >>>>>> data, or even have a macro type the data, into the document? Graham Mayor - 04 Feb 2008 15:12 GMT To do what you ask literally -
Dim AC As AutoCorrectEntry Dim sAC1 As String Dim sAC2 As String Dim sAC3 As String Dim dEXCEL As DataObject With Application For Each AC In .Autocorrect.Entries With AC If .Name = "MRN" Then sAC1 = .Value End If If .Name = "PP" Then sAC2 = .Value End If If .Name = "UU" Then sAC3 = .Value End If End With Next AC Set dEXCEL = New DataObject dEXCEL.SetText sAC3 & vbTab & sAC2 & vbTab & sAC1 dEXCEL.PutInClipboard End With
However it should be possible to fire up Excel and paste the entry in there or insert it without recourse to the clipboard or manual intervention, but sadly I don't know much about the Excel model.
 Signature <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP
My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Hi Summer, > [quoted text clipped - 82 lines] >>>>> to type the data, or even have a macro type the data, into the >>>>> document? Graham Mayor - 04 Feb 2008 15:25 GMT I see events overtook me while I nipped out for a break ;)
 Signature <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP
My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> To do what you ask literally - > [quoted text clipped - 112 lines] >>>>>> to type the data, or even have a macro type the data, into the >>>>>> document? Alan Stancliff - 04 Feb 2008 23:53 GMT And thanks to you, to Graham, for the help. Also, I benefited greatly from the link you gave me on the link to your help on setting up a newsreader to connect to this forum here:
http://www.gmayor.com/MSNews.htm
I had all kinds of problems with the incredibly clunky Microsoft web forum software.
Regards,
Alan Stancliff
> To do what you ask literally - > [quoted text clipped - 25 lines] > or insert it without recourse to the clipboard or manual intervention, but > sadly I don't know much about the Excel model.
|
|
|