ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to pass arguments to an Excel macro using Dynamic Data Exchang (https://www.excelbanter.com/excel-programming/390577-how-pass-arguments-excel-macro-using-dynamic-data-exchang.html)

Ted

How to pass arguments to an Excel macro using Dynamic Data Exchang
 
Background:
I'm trying to pass arguments to an Excel macro using Dynamic Data Exchange
(DDE).

I can pass arguments to this Excel macro within Excel (not using DDE) with
the following format, note the lack of parenthesis:
Application.Run "Personal.xls!MacroName", Arg1, Arg2, Arg3

I can also pass control to this Excel macro using DDE from another Office
application (Word) without arguments using the following format (note the
presence of parenthesis and brackets):
[Application.Run("Personal.xls!MacroName")]

However, when including arguments (using the above parenthesis and bracket
format) from Word, I get Error Code 4599 "Process failed in other
application."

Question:
How to pass arguments to an Excel macro using Dynamic Data Exchange (DDE)?

--
Ted

RB Smissaert

How to pass arguments to an Excel macro using Dynamic Data Exchang
 
Why use DDE?
Just use OLE automation and then you do things like this:

oXLApp.Run "XLFile.xls!Module1.Sub1", Arg1, Arg2, Arg3

RBS


"Ted" wrote in message
...
Background:
I'm trying to pass arguments to an Excel macro using Dynamic Data Exchange
(DDE).

I can pass arguments to this Excel macro within Excel (not using DDE) with
the following format, note the lack of parenthesis:
Application.Run "Personal.xls!MacroName", Arg1, Arg2, Arg3

I can also pass control to this Excel macro using DDE from another Office
application (Word) without arguments using the following format (note the
presence of parenthesis and brackets):
[Application.Run("Personal.xls!MacroName")]

However, when including arguments (using the above parenthesis and bracket
format) from Word, I get Error Code 4599 "Process failed in other
application."

Question:
How to pass arguments to an Excel macro using Dynamic Data Exchange (DDE)?

--
Ted



Ted

How to pass arguments to an Excel macro using Dynamic Data Exc
 
RB Smissaert,

Thank you for responding to my query concerning DDE.
Eventhough your reponse was not what I was hoping for,
it did force me to learn about OLE Automation.

I thought that in addition to your comment, "with OLE one can do things like:

oXLApp.Run "XLFile.xls!Module1.Sub1", Arg1, Arg2, Arg3

all I needed in my VBA OLE code prior to the Run statement was:

Dim oXLapp As Excel.Application
Set oXLapp = CreateObject("Excel.Application")

It took me 3 weeks to learn that when one Automates Excel, the
Personal.xls workbook (if present) is not automatically opened
(albeit hidden) as is the case when one invokes Excel from the
Desktop environment. Therefore, one must mannually open this
file with OLE Automation.

oXLapp.Workbooks.Open ("C:\Documents and Settings\...\Personal.xls")

Eventhough with DDE one's personal.xls file is automatically opened,
one cannot pass arguments to Excel using DDE but one can with OLE.

Thank you so much for pointing me in the right direction

Ted

--
Ted


"RB Smissaert" wrote:

Why use DDE?
Just use OLE automation and then you do things like this:

oXLApp.Run "XLFile.xls!Module1.Sub1", Arg1, Arg2, Arg3

RBS


"Ted" wrote in message
...
Background:
I'm trying to pass arguments to an Excel macro using Dynamic Data Exchange
(DDE).

I can pass arguments to this Excel macro within Excel (not using DDE) with
the following format, note the lack of parenthesis:
Application.Run "Personal.xls!MacroName", Arg1, Arg2, Arg3

I can also pass control to this Excel macro using DDE from another Office
application (Word) without arguments using the following format (note the
presence of parenthesis and brackets):
[Application.Run("Personal.xls!MacroName")]

However, when including arguments (using the above parenthesis and bracket
format) from Word, I get Error Code 4599 "Process failed in other
application."

Question:
How to pass arguments to an Excel macro using Dynamic Data Exchange (DDE)?

--
Ted





All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com