Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Passing variables to another procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kerri - 04 Apr 2007 18:48 GMT
Hi all,

I have created a macro in Word 2003.  How can I make one macro have
three different results.  In other words.  I can copy the macro three
times and give it different names so the users can have a choice of
choose w/o date, w/date or w/date and time.  Originally I created user
form so they could choose one of the three options and then passed
that variable result in to a case select statement in my macro.  The
powers that be don't want the extra step of clicking in the user
form.  They want to choose from the menu one of the three choices and
have it run the macro.

I was trying to avoid having the macro created three times...incase I
need to make a change and update it later.  So, what I thought of was
to have a macro that calls the main macro, and use a variable that
will be pulled down in to the main macro.  I hope this makes sence?
Here is what I tired with no luck.
Kerri

'This would be the macro that would be in the menu
Sub FtrInfoNOdate()
'I read that if you put the variable in the "(strDateOption )" that
you can call it in other macros, but then it doesn't know what macro
to run...so obviously I'm interpreting it wrong  Dim
 Dim strDateOption As String
   strDateOption = "No Date"
   MainMacro
End Sub

'This would be the macro that would be in the menu
Sub FtrInfoYESdate()
 'I read that if you put the variable in the "()" that you can call
it in other macros
 Dim strDateOption As String
   strDateOption = "Yes insert Date"
   MainMacro
End Sub

'This would be the macro that would be in the menu
Sub FtrInfoYESdateTime()
 'I read that if you put the variable in the "()" that you can call
it in other macros
 Dim strDateOption As String
   strDateOption = "Yes insert Date & Time"
   MainMacro
End Sub

'==============
Sub MainMacro()
Dim strDateOption As String
Select Case strDateOption

  Case "No Date"
   'using msgbox as example to see its working...I'll replace with
actual code later
    MsgBox "Do not insert Date"

  Case "Yes Date"
    MsgBox "Yes insert Date"

  Case "Yes Date & Time"
    MsgBox "Yes insert Date & Time"

End Select
'do other things here...
End Sub
old man - 05 Apr 2007 20:24 GMT
Hi,

I created a routine that can process three different strings passed to it:

testcall invokes call3.

old man

Sub testcall()
call3 ("Show nothing")

End Sub
Sub call3(passedvar As String)
Select Case passedvar
   Case "Show date"
       MsgBox "date"
   Case "Show date and time"
       MsgBox "Now we are in show date and time"
   Case "Show nothing"
       MsgBox "Im just watching..."
   Case Else
       MsgBox "I don't understand..."
End Select

End Sub

> Hi all,
>
[quoted text clipped - 62 lines]
> 'do other things here...
> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.