From: Tith on
I'm in need of a macro to help me format upwards of 10000 word files. I have
the two macros I will need to format each word doc, but I would like to
automate this further by running it on a directory (including
sub-directories). I'm not very familar with VBA so I'm stumbling through it.

these reports will either have 4 or 5 inline images and each will have to be
treated a little dirfferently. I have created the macros for those two
situations.

Sub ChooseMacro()
'
' Macro3 ChooseMacro
' Macro created 3/24/2010 by tith
' Determines which macro to run, Macro1() or Macro2()
'
Dim iShapeCount As Integer
Dim tmpMsg As String
Set ThisDoc = ActiveDocument

iShapeCount = ThisDoc.InlineShapes.Count

If iShapeCount = 4 Then
' How do I call a macro inside a macro?
' Macro1()
tmpMsg = "Run Macro1()"
MsgBox (tmpMsg)
ElseIf iShapeCount = 5 Then
' How do I call a macro inside a macro?
' Macro2()
tmpMsg = "Run Macro2()"
MsgBox (tmpMsg)
Else
' Do nothing

End If

End Sub


From: Pesach Shelnitz on
Hi,

To call a macro from a macro, just write the name of the macro to be called.
For example, in the following two macros, when you run Macro1, it calls Macro
2.

Sub Macro1()
Macro2
End Sub

Sub Macro2()
MsgBox ("Hello World")
End Sub

You can also add the keyword Call before Macro2 in Macro1.

--
Hope this helps,
Pesach Shelnitz
My Web site: http://makeofficework.com


"Tith" wrote:

> I'm in need of a macro to help me format upwards of 10000 word files. I have
> the two macros I will need to format each word doc, but I would like to
> automate this further by running it on a directory (including
> sub-directories). I'm not very familar with VBA so I'm stumbling through it.
>
> these reports will either have 4 or 5 inline images and each will have to be
> treated a little dirfferently. I have created the macros for those two
> situations.
>
> Sub ChooseMacro()
> '
> ' Macro3 ChooseMacro
> ' Macro created 3/24/2010 by tith
> ' Determines which macro to run, Macro1() or Macro2()
> '
> Dim iShapeCount As Integer
> Dim tmpMsg As String
> Set ThisDoc = ActiveDocument
>
> iShapeCount = ThisDoc.InlineShapes.Count
>
> If iShapeCount = 4 Then
> ' How do I call a macro inside a macro?
> ' Macro1()
> tmpMsg = "Run Macro1()"
> MsgBox (tmpMsg)
> ElseIf iShapeCount = 5 Then
> ' How do I call a macro inside a macro?
> ' Macro2()
> tmpMsg = "Run Macro2()"
> MsgBox (tmpMsg)
> Else
> ' Do nothing
>
> End If
>
> End Sub
>
>
From: Greg Maxey on
If, as it sort of appears, you are trying to get a result from Macro1 or
Macro2 then you would use a Function:

Sub ChooseMacro()
Dim iShapeCount As Integer
iShapeCount = ActiveDocument.InlineShapes.Count
Select Case iShapeCount
Case Is = 4
MsgBox Macro1
Case Is = 5
MsgBox Macro2
Case Else
'Do nothing
End Select
End Sub

Function Macro1() As String
Macro1 = "I'm Macro1 result"
End Function

Function Macro2() As String
Macro2 = "I'm Macro2 result"
End Function





"Tith" <Tith(a)discussions.microsoft.com> wrote in message
news:B1B1385C-ABA3-4549-8D89-27D1F9D019E1(a)microsoft.com...
> I'm in need of a macro to help me format upwards of 10000 word files. I
> have
> the two macros I will need to format each word doc, but I would like to
> automate this further by running it on a directory (including
> sub-directories). I'm not very familar with VBA so I'm stumbling through
> it.
>
> these reports will either have 4 or 5 inline images and each will have to
> be
> treated a little dirfferently. I have created the macros for those two
> situations.
>
> Sub ChooseMacro()
> '
> ' Macro3 ChooseMacro
> ' Macro created 3/24/2010 by tith
> ' Determines which macro to run, Macro1() or Macro2()
> '
> Dim iShapeCount As Integer
> Dim tmpMsg As String
> Set ThisDoc = ActiveDocument
>
> iShapeCount = ThisDoc.InlineShapes.Count
>
> If iShapeCount = 4 Then
> ' How do I call a macro inside a macro?
> ' Macro1()
> tmpMsg = "Run Macro1()"
> MsgBox (tmpMsg)
> ElseIf iShapeCount = 5 Then
> ' How do I call a macro inside a macro?
> ' Macro2()
> tmpMsg = "Run Macro2()"
> MsgBox (tmpMsg)
> Else
> ' Do nothing
>
> End If
>
> End Sub
>
>


From: Guessed on
The code to run your macro across all the files in a directory can be found
in this thread.
http://www.eileenslounge.com/viewtopic.php?f=26&t=1375

--
Andrew Lockton
From: Tith on
Thanks the link was very helpful.

I know what I wanted to do, but I wasn't sure how to go about it in VBA.
Thank you!

"Guessed" wrote:

> The code to run your macro across all the files in a directory can be found
> in this thread.
> http://www.eileenslounge.com/viewtopic.php?f=26&t=1375
>
> --
> Andrew Lockton