Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking macros

Status
Not open for further replies.

glindhot

Technical User
Joined
Dec 5, 2006
Messages
2
Location
AU
Shown below are two MS Word macros. Each one shows its code from Sub to End Sub

They both work perfectly. The trouble is that I have to run them individually because the first macro turns Word off after it has run. I then have to reload Word to run the second macro.

What I would like to do is link the macros so that they both run when I set the first macro going. How must the code be modified to do the job?

Sub AUSENG()
'
' AUSENG Macro
' Macro recorded 12/5/2006 by G Lind
'
Selection.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.8", FileName:= _
"C:\excel\t2t-1-2.xls", LinkToFile:=False, DisplayAsIcon:=False
ActiveDocument.SaveAs FileName:="\homepage\cricket\gametest\t2t-1-2.htm", FileFormat:=wdFormatHTML, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ActiveWindow.View.Type = wdWebView
Application.Quit
End Sub

Sub ENGAUS()
'
' ENGAUS Macro
' Macro recorded 12/5/2006 by G Lind
'
Selection.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.8", FileName:= _
"C:\excel\t2t-2-1.xls", LinkToFile:=False, DisplayAsIcon:=False
ActiveDocument.SaveAs FileName:="\homepage\cricket\gametest\t2t-2-1.htm", FileFormat:=wdFormatHTML, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ActiveWindow.View.Type = wdWebView
Application.Quit
End Sub
 
Why not just combine them into a single macro?

If there's a good reason not to do that, then you can call one sub from another:
Code:
Sub AUSENG()
...
[b]Call ENGAUS[/b]
    Application.Quit
End Sub

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
John,
Many thanks for your help.
I installed the 'Call' code you listed.
I then added several more 'Call' links and it was wonderful to watch them all go whistling by and pop up with just what I wanted.

Your alternative suggestion of "Why not just combine them into a single macro?" would also work fine. My problem is that I am not conversant with this particular programming language. Would you please show me the code changes needed to make a single macro?

 
The combining could be accomplished by simply deleting the following lines from your original post:

Code:
    Application.Quit
End Sub

Sub ENGAUS()
'
' ENGAUS Macro
' Macro recorded 12/5/2006 by G Lind

That is, just delete the end of the first and the start of the second.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top