Macro question

  • Thread starter Thread starter Menno Hershberger
  • Start date Start date
M

Menno Hershberger

I need to set up a simple macro that will input "######" (a 6 number
sequence) with one keystroke.
I've run into a situation where I need to type every phone number in town
into a form... along with related info. It has to be the full 10 digit
number with area code and prefix. So the first 6 numbers will always be the
same.
I'd like to just hit like F7 or something to input the first 6 numbers and
then just type in the remaining 4.
This would have to be a Windows thing because the specialized software
we're using doesn't have any provisions for hotkeys.
I used to set up stuff like that in DOS, but don't have a clue about how to
do it in Windows.
Can anybody help?
 
Menno Hershberger said:
I need to set up a simple macro that will input "######" (a 6 number
sequence) with one keystroke.
I've run into a situation where I need to type every phone number in town
into a form... along with related info. It has to be the full 10 digit
number with area code and prefix. So the first 6 numbers will always be
the
same.
I'd like to just hit like F7 or something to input the first 6 numbers and
then just type in the remaining 4.
This would have to be a Windows thing because the specialized software
we're using doesn't have any provisions for hotkeys.
I used to set up stuff like that in DOS, but don't have a clue about how
to
do it in Windows.
Can anybody help?

You could create the file c:\windows\Prefix.vbs
and put these lines inside:

Set ws=CreateObject("WScript.Shell")
ws.AppActivate("YourAppName")
ws.sendkeys("111222")

YourAppName is the name of your application, e.g.
Microsoft Excel - Book1. Just check what it says in
the Title Bar when the application is open.

Now create a shortcut on the desktop with these properties:

Target = cscript.exe c:\windows\Prefix.vbs
Shortcut key = F7
 
Really ? ...that's what I had to do when I wanted to make a Windows macro.
i.e. there's hundreds of tutorials out there, that lead you through making a
Windows macro, which meant I had to find out a few odds and ends about the
Windows scripting host ! ...and as with EVERYTHING to do with a PC whether
it be hardware or software, time WHISTLES past. It took the odd half hour
or so, and a bit of trial and error ...mind you it was so long ago I'd have
toread up on it all again ! :-)

regards, Richard
 
If it took you only half an hour to get into VB Scripts as a beginner
then you must be a genius. Congratulations!
 
...alright, ...several half hours or so !
....and I was a genius but, nowadays I seem to be forgetting more than I can
remember :-)
....and I did own up the fact that I can't remember how to make a Windows
macro, but, I could remember how I found out how to make one a long time ago
! :-)

regards, Richard
 
any reason to not "copy" the the first 6 digits and then "paste" them
using Ctrl-V or Shift Insert?
 
After the number is entered, there are several other fields that I use copy
and paste on, so by the next time I'm ready to enter a number, it would be
out of the clipboard. But now that you mention it, I remember a program
called ClipMate that saves previous clipboard contents. If there were a
fast way to restore that number in the clipboard, I'd go for that. I'm
going to try Pegasus's idea first.
 
You could create the file c:\windows\Prefix.vbs
and put these lines inside:

Set ws=CreateObject("WScript.Shell")
ws.AppActivate("YourAppName")
ws.sendkeys("111222")

YourAppName is the name of your application, e.g.
Microsoft Excel - Book1. Just check what it says in
the Title Bar when the application is open.

Now create a shortcut on the desktop with these properties:

Target = cscript.exe c:\windows\Prefix.vbs
Shortcut key = F7

You're my hero!
It took a little playing around with YourAppName but when I finally got
it right, it worked like a charm.
Thanks!
 
Menno Hershberger said:
You're my hero!
It took a little playing around with YourAppName but when I finally got
it right, it worked like a charm.
Thanks!

Glad it worked for you, and thanks for the feedback.
 
Pegasus,

Technically the OP asked for a macro which is VBA not VBS

-----------------

Send keys won't work if the focus is removed

The user has a text field & if there are multiple text fields/controls then you
will need to tab to that control first. So, if the OP launches his application &
EXIT is the default then your sendkeys will be trying to type into a button,
which isn't going to work
 
25 years ago, I was the one who figured stuff out for myself and answered
questions for other people. Now, at 70, I've absorbed about all the
knowledge I can stand. I'm not too proud anymore to ask help from someone
who already has something figured out.

I just read something somewhere to the effect that the reason old people
get forgetful is that because the older you get, the more stuff you have
to remember... :-)
 
25 years ago, I was the one who figured stuff out for myself and answered
questions for other people. Now, at 70, I've absorbed about all the
knowledge I can stand.


I am also 70 (or will be in a month and a half), but I haven't stopped
learning yet. I hope never to stop until the day I die.

I'm not too proud anymore to ask help from someone
who already has something figured out.


I never was. Most of what I know I learned from someone else--in
person, in books, on the internet, etc. Comparatively few things can
be learned from personal experience (I'm not just talking about
computer things here).

I just read something somewhere to the effect that the reason old people
get forgetful is that because the older you get, the more stuff you have
to remember... :-)



I can't remember whether I read that or not. ;-)
 
"Comparatively few things can be learned from personal experience (I'm not
just talking about
computer things here)."

For some tenouous reason, your above comment brought to mind the several
times, across several days, many years ago, that I stubbornly sat in front
of my PC, (with 2 x 5 1/4" floppy drives and no hard-disk), until the
"penny-dropped" (for me almost a "Eureka" moment:-), and fought with MSDOS
until it "clicked" as to how the damned file storage / directory structure
worked !!!!
i.e. "tree branch" directories within directories, and files within
directories ! ...it was SUCH a relief when that penny dropped !

....oh happy days !

regards, Richard
 
Back
Top