_Application.Run(Object, Object, Object, Object, Object, Object, Object, Object
Advertisement

Runs a macro or calls a function.

public object Run (object Macro, object Arg1, object Arg2, object Arg3, object Arg4, object Arg5, object Arg6, object Arg7, object Arg8, object Arg9, object Arg10, object Arg11, object Arg12, object Arg13, object Arg14, object Arg15, object Arg16, object Arg17, object Arg18, object Arg19, object Arg20, object Arg21, object Arg22, object Arg23, object Arg24, object Arg25, object Arg26, object Arg27, object Arg28, object Arg29, object Arg30);
Public Function Run (Optional Macro As Object, Optional Arg1 As Object, Optional Arg2 As Object, Optional Arg3 As Object, Optional Arg4 As Object, Optional Arg5 As Object, Optional Arg6 As Object, Optional Arg7 As Object, Optional Arg8 As Object, Optional Arg9 As Object, Optional Arg10 As Object, Optional Arg11 As Object, Optional Arg12 As Object, Optional Arg13 As Object, Optional Arg14 As Object, Optional Arg15 As Object, Optional Arg16 As Object, Optional Arg17 As Object, Optional Arg18 As Object, Optional Arg19 As Object, Optional Arg20 As Object, Optional Arg21 As Object, Optional Arg22 As Object, Optional Arg23 As Object, Optional Arg24 As Object, Optional Arg25 As Object, Optional Arg26 As Object, Optional Arg27 As Object, Optional Arg28 As Object, Optional Arg29 As Object, Optional Arg30 As Object) As Object

Parameters

Macro

Object

Optional Object. The macro to run. This can be either a string with the macro name, a Range object indicating where the function is, or a register ID for a registered DLL (XLL) function. If a string is used, the string will be evaluated in the context of the active sheet.

Arg1

Object

Optional Object. The arguments that should be passed to the function.

Advertisement

Arg2

Object

Optional Object. The arguments that should be passed to the function.

Arg3

Object

Optional Object. The arguments that should be passed to the function.

Arg4

Object

Optional Object. The arguments that should be passed to the function.

Arg5

Object

Optional Object. The arguments that should be passed to the function.

Arg6

Object

Optional Object. The arguments that should be passed to the function.

Arg7

Object

Optional Object. The arguments that should be passed to the function.

Arg8

Object

Optional Object. The arguments that should be passed to the function.

Arg9

Object

Optional Object. The arguments that should be passed to the function.

Arg10

Object

Optional Object. The arguments that should be passed to the function.

Arg11

Object

Optional Object. The arguments that should be passed to the function.

Arg12

Object

Optional Object. The arguments that should be passed to the function.

Arg13

Object

Optional Object. The arguments that should be passed to the function.

Arg14

Object

Optional Object. The arguments that should be passed to the function.

Arg15

Object

Optional Object. The arguments that should be passed to the function.

Arg16

Object

Optional Object. The arguments that should be passed to the function.

Arg17

Object

Optional Object. The arguments that should be passed to the function.

Arg18

Object

Optional Object. The arguments that should be passed to the function.

Arg19

Object

Optional Object. The arguments that should be passed to the function.

Arg20

Object

Optional Object. The arguments that should be passed to the function.

Arg21

Object

Optional Object. The arguments that should be passed to the function.

Arg22

Object

Optional Object. The arguments that should be passed to the function.

Arg23

Object

Optional Object. The arguments that should be passed to the function.

Arg24

Object

Optional Object. The arguments that should be passed to the function.

Arg25

Object

Optional Object. The arguments that should be passed to the function.

Arg26

Object

Optional Object. The arguments that should be passed to the function.

Arg27

Object

Optional Object. The arguments that should be passed to the function.

Arg28

Object

Optional Object. The arguments that should be passed to the function.

Arg29

Object

Optional Object. The arguments that should be passed to the function.

Arg30

Object

Optional Object. The arguments that should be passed to the function.

Returns

Object

Remarks

You cannot use named arguments with this method. Arguments must be passed by position.

The Run method returns whatever the called macro returns. Objects passed as arguments to the macro are converted to values (by applying the Value property to the object). This means that you cannot pass objects to macros by using the Run method.

Applies to

Join the pack! Join 8000+ others registered users, and get chat, make groups, post updates and make friends around the world!
www.knowasiak.com/register/
Read More

Advertisement

2 Comments

  1. Well, not sure why that's implemented as is, interop is some old technology and there are quirks or whatever. But .NET provides convenience methods/delegates, like typed Action<>[1] (or Func<>) with 16 arguments, so you don't have to explicitly define delegate yourself:
    [1] https://docs.microsoft.com/en-us/dotnet/api/system.action-16…

    Today as of C# 4 you can for example have optional arguments. Not sure if this applies to this method which surely predates C#4.

  2. "Why not just pass an array of arguments?"

    Speed and convenience, I'd imagine? IIRC, arrays are marshalled as SAFEARRAYs in COM and those things are quite heavy-weight, you'd really rather call a 31-parameter function and pass it 27 NULLs in places of extraneous parameters.