Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro Runs Twice

Hi all,

We are using Excel for reporting in our organization. Basically there is a
Java web application which instantiates Excel 2007 with an XLAM. This XLAM
opens a Report Template(an .xls, .xlsm file, name supplied as command line
parameter). The Template has a datasheet where we have multiple ranges and
the Reportsheet which shows the final report based on the data from the
Datasheet. The Reportsheet contains formulas to show the final output. It
could contain Charts/Graphs also. The data is fetched from SQL server and is
pasted on the Ranges. And finally when all the data is pasted and Macro is
run the Template is saved as a Final Report somewhere on the Report Server.

The Excel runs in the background in all this process. There could be
multiple instances of Excel running on the same box. The instances run under
separate WindowStation.

In this process depending on the options selected by the end user, the
Report options are applied on the final report workbook. The some of the
Report options are Run User Macro, Protect Workbook, Protect Worksheets,
Delete Macro code, etc.

I am facing a problem when it comes to running user Macro.

This is how I execute the macro present in the templte.

Application.Run(<macro name)

The <macro name passed above could have parenthesis in it e.g.
"MacroTest()" or the <macro name could have parameters e.g. "MacroTest(1,
1231)"

If the <macro name is not stripped off the parenthesis then the macro gets
executed twice. When the macro has parameters then the parenthesis could not
be stripped off and the macro gets executed twice.

If anybody have any idea please let me know as it is a blocking issue in our
process.

Any help appreciated.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Macro Runs Twice

Try running the code manually to debug, it sounds there is a lot going on
and unless you isolate the possible areas it will be impossible to remotely
diagnose.

--

Regards,
Nigel




"Anand Nichkaode" wrote in
message ...
Hi all,

We are using Excel for reporting in our organization. Basically there is a
Java web application which instantiates Excel 2007 with an XLAM. This XLAM
opens a Report Template(an .xls, .xlsm file, name supplied as command line
parameter). The Template has a datasheet where we have multiple ranges and
the Reportsheet which shows the final report based on the data from the
Datasheet. The Reportsheet contains formulas to show the final output. It
could contain Charts/Graphs also. The data is fetched from SQL server and
is
pasted on the Ranges. And finally when all the data is pasted and Macro is
run the Template is saved as a Final Report somewhere on the Report
Server.

The Excel runs in the background in all this process. There could be
multiple instances of Excel running on the same box. The instances run
under
separate WindowStation.

In this process depending on the options selected by the end user, the
Report options are applied on the final report workbook. The some of the
Report options are Run User Macro, Protect Workbook, Protect Worksheets,
Delete Macro code, etc.

I am facing a problem when it comes to running user Macro.

This is how I execute the macro present in the templte.

Application.Run(<macro name)

The <macro name passed above could have parenthesis in it e.g.
"MacroTest()" or the <macro name could have parameters e.g. "MacroTest(1,
1231)"

If the <macro name is not stripped off the parenthesis then the macro
gets
executed twice. When the macro has parameters then the parenthesis could
not
be stripped off and the macro gets executed twice.

If anybody have any idea please let me know as it is a blocking issue in
our
process.

Any help appreciated.

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro Runs Twice

The macro when run independently runs once.

The way it is called i.e. Application.Run("MacroTest(1,123)") is wrong and
right way is Application.Run("MacroTest, 1, 123")

You can do a simple test on your side by calling a macro with parethesis, it
should run twice. The macro need not have parameters.

-Thx
Anand

"Nigel" wrote:

Try running the code manually to debug, it sounds there is a lot going on
and unless you isolate the possible areas it will be impossible to remotely
diagnose.

--

Regards,
Nigel




"Anand Nichkaode" wrote in
message ...
Hi all,

We are using Excel for reporting in our organization. Basically there is a
Java web application which instantiates Excel 2007 with an XLAM. This XLAM
opens a Report Template(an .xls, .xlsm file, name supplied as command line
parameter). The Template has a datasheet where we have multiple ranges and
the Reportsheet which shows the final report based on the data from the
Datasheet. The Reportsheet contains formulas to show the final output. It
could contain Charts/Graphs also. The data is fetched from SQL server and
is
pasted on the Ranges. And finally when all the data is pasted and Macro is
run the Template is saved as a Final Report somewhere on the Report
Server.

The Excel runs in the background in all this process. There could be
multiple instances of Excel running on the same box. The instances run
under
separate WindowStation.

In this process depending on the options selected by the end user, the
Report options are applied on the final report workbook. The some of the
Report options are Run User Macro, Protect Workbook, Protect Worksheets,
Delete Macro code, etc.

I am facing a problem when it comes to running user Macro.

This is how I execute the macro present in the templte.

Application.Run(<macro name)

The <macro name passed above could have parenthesis in it e.g.
"MacroTest()" or the <macro name could have parameters e.g. "MacroTest(1,
1231)"

If the <macro name is not stripped off the parenthesis then the macro
gets
executed twice. When the macro has parameters then the parenthesis could
not
be stripped off and the macro gets executed twice.

If anybody have any idea please let me know as it is a blocking issue in
our
process.

Any help appreciated.

Thanks in advance.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro Runs Twice

Remove the ()'s.

Application.Run(<macro name)

should be

Application.Run <macro name




Anand Nichkaode wrote:

Hi all,

We are using Excel for reporting in our organization. Basically there is a
Java web application which instantiates Excel 2007 with an XLAM. This XLAM
opens a Report Template(an .xls, .xlsm file, name supplied as command line
parameter). The Template has a datasheet where we have multiple ranges and
the Reportsheet which shows the final report based on the data from the
Datasheet. The Reportsheet contains formulas to show the final output. It
could contain Charts/Graphs also. The data is fetched from SQL server and is
pasted on the Ranges. And finally when all the data is pasted and Macro is
run the Template is saved as a Final Report somewhere on the Report Server.

The Excel runs in the background in all this process. There could be
multiple instances of Excel running on the same box. The instances run under
separate WindowStation.

In this process depending on the options selected by the end user, the
Report options are applied on the final report workbook. The some of the
Report options are Run User Macro, Protect Workbook, Protect Worksheets,
Delete Macro code, etc.

I am facing a problem when it comes to running user Macro.

This is how I execute the macro present in the templte.

Application.Run(<macro name)

The <macro name passed above could have parenthesis in it e.g.
"MacroTest()" or the <macro name could have parameters e.g. "MacroTest(1,
1231)"

If the <macro name is not stripped off the parenthesis then the macro gets
executed twice. When the macro has parameters then the parenthesis could not
be stripped off and the macro gets executed twice.

If anybody have any idea please let me know as it is a blocking issue in our
process.

Any help appreciated.

Thanks in advance.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Macro runs upon wkbk open, but no Workbook_Open or Auto_Open Macro Ron Coderre Excel Programming 2 September 26th 06 05:50 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Which Macro Runs...? Bill Martin Excel Discussion (Misc queries) 7 September 29th 05 12:42 PM
Macro runs in source , but not when in Personal Macro Workbook Darin Kramer Excel Programming 1 September 13th 05 04:48 PM


All times are GMT +1. The time now is 09:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"