Calling Excel from Word.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
I have a sub in Excel called ChooseRegion, Excel syntax:<o
></o
>
ChooseRegion 2<o
></o
>
Or <o
></o
>
Call ChooseRegion(2)<o
></o
>
<o
></o
>
I have a Sub called Reset which resets Excel to the top of the list:<o
></o
>
Excel:<o
></o
>
Call ChooseRegion(0)<o
></o
>
This works fine
<o
></o
>
<o
></o
>
Syntax From Word:<o
></o
>
objExcel.Application.Run ("Reset")<o
></o
>
This runs within Excel<o
></o
>
Call ChooseRegion(0)<o
></o
>
This works fine
<o
></o
>
<o
></o
>
But<o
></o
>
Syntax From Word:<o
></o
>
objExcel.Application.Run ("ChooseRegion(2)")<o
></o
>
Doesn't run the macro
<o
></o
>
<o
></o
>
The help suggests the following syntax:<o
></o
>
objExcel.Application.Run ("ChooseRegion" ,"2")
<o
></o
>
But the VBA editor claims that this is bad syntax and flags it as Red<o
></o
>
<o
></o
>
Details about the functionality:<o
></o
>
The chooseRegion macro sets the filter name in a data matrix for a chart. Word opens Excel, retrieves data from an External Database, filters the data and plots a chart. It then copies this chart into Word. There are 12 Regions. <o
></o
>
<o
></o
>
Office 2003, Windows XP<o
></o
>
<o
></o
>
Any ideas as the the correct syntax?
This is in Excel as a Module:
Public Sub ChooseRegion(RegionNum As Integer)
Sheets("Chart").Select
Range("SelRegion").Value = RegionNum
RegionName = Sheets("Info").Range("RegionName") 'This is a VLookup
Selection.AutoFilter Field:=2, Criteria1:=RegionName
Debug.Print "Chosen Region: " & RegionName
End Sub<o
></o
>




I have a sub in Excel called ChooseRegion, Excel syntax:<o


ChooseRegion 2<o


Or <o


Call ChooseRegion(2)<o


<o


I have a Sub called Reset which resets Excel to the top of the list:<o


Excel:<o


Call ChooseRegion(0)<o


This works fine



<o


Syntax From Word:<o


objExcel.Application.Run ("Reset")<o


This runs within Excel<o


Call ChooseRegion(0)<o


This works fine



<o


But<o


Syntax From Word:<o


objExcel.Application.Run ("ChooseRegion(2)")<o


Doesn't run the macro



<o


The help suggests the following syntax:<o


objExcel.Application.Run ("ChooseRegion" ,"2")



But the VBA editor claims that this is bad syntax and flags it as Red<o


<o


Details about the functionality:<o


The chooseRegion macro sets the filter name in a data matrix for a chart. Word opens Excel, retrieves data from an External Database, filters the data and plots a chart. It then copies this chart into Word. There are 12 Regions. <o


<o


Office 2003, Windows XP<o


<o


Any ideas as the the correct syntax?
This is in Excel as a Module:
Public Sub ChooseRegion(RegionNum As Integer)
Sheets("Chart").Select
Range("SelRegion").Value = RegionNum
RegionName = Sheets("Info").Range("RegionName") 'This is a VLookup
Selection.AutoFilter Field:=2, Criteria1:=RegionName
Debug.Print "Chosen Region: " & RegionName
End Sub<o

