Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Running a macro from windows application

I need to run an Excel macro that is contained in the "ThisWorkbook" Module
of the file from a windows application. Can this be done. If so ...please
help me out with the code.

I tried OBJExcelWorkbook.Application.Run("MyMacro",missing ,missing......)
but it says macro cant be found. I think this is because it is inside
"ThisWorkbook". Please help.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Running a macro from windows application

This is how I would do it in VBA (from within excel and from within the same
project):

'inside the ThisWorkbook module
'notice the Public keyword
Option Explicit
Public Sub myMacro(str1 As String, str2 As String)
MsgBox str1 & vbLf & str2
End Sub

And from a General module:
Option Explicit
Sub testme()
Application.Run "thisworkbook.mymacro", "asdf", "qwer"
End Sub

=====
Actually, I would try to put any subroutine that isn't a workbook event in a
general module (well, most the time).


Aerojade wrote:

I need to run an Excel macro that is contained in the "ThisWorkbook" Module
of the file from a windows application. Can this be done. If so ...please
help me out with the code.

I tried OBJExcelWorkbook.Application.Run("MyMacro",missing ,missing......)
but it says macro cant be found. I think this is because it is inside
"ThisWorkbook". Please help.

Thanks


--

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
can i record a macro from excel to invvoke another windows application anil Excel Discussion (Misc queries) 2 March 30th 07 01:04 PM
Please free the Application Windows in Office 2007 DaveEv Excel Discussion (Misc queries) 0 October 22nd 06 12:29 PM
Windows application error message Tony Tong Excel Discussion (Misc queries) 0 September 15th 06 07:30 AM
separate application windows JC Excel Discussion (Misc queries) 0 June 29th 06 02:21 PM
How to keep userform always on the top of all windows application JAtz_DA_WAY Excel Discussion (Misc queries) 1 August 31st 05 01:29 AM


All times are GMT +1. The time now is 09:23 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"