View Single Post
 
Old 10-31-2011, 05:40 PM
Paulsh Paulsh is offline Windows XP Office 2010 32bit
Novice
 
Join Date: Oct 2011
Posts: 1
Paulsh is on a distinguished road
Default Call Macro from Input Box String

I am trying to write a macro for Word 2010 to type the name and typist at the end of a letter. I want the typist to the sender's initials such as "jas" in an InputBox and then call the macro "jas" which will then type "John A. Smith." There are multiple initials-name macros that could be called to type the name of a particular sender.

I've been pulling my hair our reading up on and experimenting with "PassByRef" and "Call," etc. and have found 300+ different way not to write the code.

The code would (simply) look like this:
Dim strSender As String
Dim strTypist As String
' selection and cursor movement omitted here for brevity
strSender = InputBox("Enter Sender's Initials:", "SENDER")

Call (strSender)
' it's at this point the "jas" macro would type "John A. Smith"
Selection.TypeParagraph
Selection.TypeParagraph

Selection.TypeText Text:=strSender
Selection.TypeText Text:="/"
strTypist = InputBox("Enter Typist's Initials:", "TYPIST")
Selection.TypeText Text:=strTypist
I did this in WordPerfect years ago by using "nest" and "get." We're converts to all Word now and VBA has me stumped on this one.

Any assistance in solving this dilemma would be greatly appreciated.

Thank you.

Paulsh
Reply With Quote