A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Call macro stored in Excel workbook from Outlook's macro



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 1st 06, 10:16 PM posted to microsoft.public.outlook.program_vba
Gvaram
external usenet poster
 
Posts: 14
Default Call macro stored in Excel workbook from Outlook's macro

I'd like to run macro function "ExcelTestMacro" stored in "C:\Test.xls"
(which is already open), when the new mail massage comes.

I can call macro in Outlook from Excel easily for example by :
Call ", "Test","C:\test.xls")

But I could not call Excel macro from Outlook that way.
I allowed access to Visual basic Project and tried:
Set MyExBook = Excel.Application.Workbooks.open("C:\Test.xls")
call MyExBook.ExcelTestMacro
but there appears Run-Time error 'Object does not support this property or
method'. Of course I'm doing something wrong...

Somebody please help and tell me what to do
  #2  
Old October 2nd 06, 05:28 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Call macro stored in Excel workbook from Outlook's macro

Am Sun, 1 Oct 2006 14:16:01 -0700 schrieb Gvaram:

The Excel Application object knows a Run method. Probably that helps.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I'd like to run macro function "ExcelTestMacro" stored in "C:\Test.xls"
(which is already open), when the new mail massage comes.

I can call macro in Outlook from Excel easily for example by :
Call ",

"Test","C:\test.xls")

But I could not call Excel macro from Outlook that way.
I allowed access to Visual basic Project and tried:
Set MyExBook = Excel.Application.Workbooks.open("C:\Test.xls")
call MyExBook.ExcelTestMacro
but there appears Run-Time error 'Object does not support this property or
method'. Of course I'm doing something wrong...

Somebody please help and tell me what to do

  #3  
Old October 2nd 06, 05:56 PM posted to microsoft.public.outlook.program_vba
Gvaram
external usenet poster
 
Posts: 14
Default Call macro stored in Excel workbook from Outlook's macro

I tried "Run" but there is the same result.
I don't know exactly, but I think the problem is in the way I'm connecting
to the excel file. I tried:
1. GetObject("C:\Test.xls")
2. Excel.Application.Workbooks.Open("C:\Test.xls")

I don't know is there any other way to open excel file and call function
stored there? Logically, if excel macro can call outlook macros, Outlook
should do the same also - both of them are microsoft products and use VBA.
But how???

Pleeease help....

"Michael Bauer [MVP - Outlook]" wrote:

Am Sun, 1 Oct 2006 14:16:01 -0700 schrieb Gvaram:

The Excel Application object knows a Run method. Probably that helps.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I'd like to run macro function "ExcelTestMacro" stored in "C:\Test.xls"
(which is already open), when the new mail massage comes.

I can call macro in Outlook from Excel easily for example by :
Call ",

"Test","C:\test.xls")

But I could not call Excel macro from Outlook that way.
I allowed access to Visual basic Project and tried:
Set MyExBook = Excel.Application.Workbooks.open("C:\Test.xls")
call MyExBook.ExcelTestMacro
but there appears Run-Time error 'Object does not support this property or
method'. Of course I'm doing something wrong...

Somebody please help and tell me what to do


  #4  
Old October 3rd 06, 07:45 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Call macro stored in Excel workbook from Outlook's macro

Am Mon, 2 Oct 2006 09:56:02 -0700 schrieb Gvaram:

Please read the VBA help for the Application.Run function, thereīs also a
sample. As I understand it, you donīt need to open the workbook, but need
the Excel Application object.

Calling Outook VBA methods from outside isnīt documented, i.e. it works for
the time being but you canīt rely on that. And thereīs no reason that it
must work for any other application, too.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I tried "Run" but there is the same result.
I don't know exactly, but I think the problem is in the way I'm connecting
to the excel file. I tried:
1. GetObject("C:\Test.xls")
2. Excel.Application.Workbooks.Open("C:\Test.xls")

I don't know is there any other way to open excel file and call function
stored there? Logically, if excel macro can call outlook macros, Outlook
should do the same also - both of them are microsoft products and use VBA.
But how???

Pleeease help....

"Michael Bauer [MVP - Outlook]" wrote:

Am Sun, 1 Oct 2006 14:16:01 -0700 schrieb Gvaram:

The Excel Application object knows a Run method. Probably that helps.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I'd like to run macro function "ExcelTestMacro" stored in "C:\Test.xls"
(which is already open), when the new mail massage comes.

I can call macro in Outlook from Excel easily for example by :
Call ",

"Test","C:\test.xls")

But I could not call Excel macro from Outlook that way.
I allowed access to Visual basic Project and tried:
Set MyExBook = Excel.Application.Workbooks.open("C:\Test.xls")
call MyExBook.ExcelTestMacro
but there appears Run-Time error 'Object does not support this property

or
method'. Of course I'm doing something wrong...

Somebody please help and tell me what to do


  #5  
Old October 3rd 06, 06:39 PM posted to microsoft.public.outlook.program_vba
Gvaram
external usenet poster
 
Posts: 14
Default Call macro stored in Excel workbook from Outlook's macro

Michael,
I read this help topic but had some problems - in outlook I wrote:
Excel.Application.run("C:Test.xls!GetDataFromMail" ,"aaaaa") , but it coused
error "The macro 'C:\Test.xls!GetDataFromMail' could not be found."

I'd like to describe the whole process in detailes to make it clear:
My target is to initiate macros in excel file when Outlook receives a new
mail . For this purpose I wrote in "ThisOutlookSession" following Sub:

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim MyMeil As Outlook.MailItem
Dim intInitial As Integer
Dim intFinal As Integer
Dim strEntryID As String
Dim intLength As Integer
intInitial = 1
intLength = Len(EntryIDCollection)
intFinal = InStr(intInitial, EntryIDCollection, ",")
strEntryID = Strings.Mid(EntryIDCollection, intInitial, (intLength -
intInitial) + 1)
Set MyMeil = Application.Session.GetItemFromID(strEntryID)
If MyMeil.Attachments.Count 0 Then
If Right(MyMeil.Attachments.Item(1).FileName, 4) = ".xls" And
InStr(1, MyMeil.Subject, "App - ") 0 Then
'!!!!!!???? Call ??????????.GetDataFromMail(strEntryID) ' HERE IS MY PROBLEM
MyMeil.UnRead = False
MyMeil.FlagIcon = olBlueFlagIcon
MyMeil.Save
Else: End If
Else: End If
End Sub

With this Sub I'm getting EntryID of recently received mail message.
On the other hand, in Excel file "C:\Test.xls" (which is already open) I
have another Sub which opens mailitem's attachment (I know EntryID from Sub
provided above), copies it in one of it's sheets and then begins processing
of data provided the

Sub GetDataFromMail(MailItemID as string)
Dim Attach As Outlook.Attachments
Dim myItem As Outlook.MailItem
Set myItem = Outlook.Application.Session.GetItemFromID(MailItem ID)
Set Attach = myItem.Attachments
Attach.Item(1).SaveAsFile ("C:\Book1200.xls")
Workbooks.Open Filename:="C:\Book1200.xls"
Sheets("Data").Select
Cells.Select
Selection.Copy
Windows("Test.xls").Activate
Sheets("DataProcessing").Select
Cells.Select
ActiveSheet.Paste
Windows("Book1200.xls").Activate
ActiveWindow.Close SaveChanges:=False
Windows("Test.xls").Activate
Range("A1").Select
Call DataProcessing 'This is another function in Excel
Kill ("C:\Book1200.xls")
Else: End If
End Sub

Individually, both Subs are functioning well.
So, the target is to call "GetDataFromMail" from "Application_NewMailEx", so
that new mail with the special excel file attachments must be processed
automatically.

Please help me to do this or tell me other solution...

"Michael Bauer [MVP - Outlook]" wrote:

Am Mon, 2 Oct 2006 09:56:02 -0700 schrieb Gvaram:

Please read the VBA help for the Application.Run function, thereÂīs also a
sample. As I understand it, you donÂīt need to open the workbook, but need
the Excel Application object.

Calling Outook VBA methods from outside isnÂīt documented, i.e. it works for
the time being but you canÂīt rely on that. And thereÂīs no reason that it
must work for any other application, too.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I tried "Run" but there is the same result.
I don't know exactly, but I think the problem is in the way I'm connecting
to the excel file. I tried:
1. GetObject("C:\Test.xls")
2. Excel.Application.Workbooks.Open("C:\Test.xls")

I don't know is there any other way to open excel file and call function
stored there? Logically, if excel macro can call outlook macros, Outlook
should do the same also - both of them are microsoft products and use VBA.
But how???

Pleeease help....

"Michael Bauer [MVP - Outlook]" wrote:

Am Sun, 1 Oct 2006 14:16:01 -0700 schrieb Gvaram:

The Excel Application object knows a Run method. Probably that helps.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I'd like to run macro function "ExcelTestMacro" stored in "C:\Test.xls"
(which is already open), when the new mail massage comes.

I can call macro in Outlook from Excel easily for example by :
Call ",
"Test","C:\test.xls")

But I could not call Excel macro from Outlook that way.
I allowed access to Visual basic Project and tried:
Set MyExBook = Excel.Application.Workbooks.open("C:\Test.xls")
call MyExBook.ExcelTestMacro
but there appears Run-Time error 'Object does not support this property

or
method'. Of course I'm doing something wrong...

Somebody please help and tell me what to do


  #6  
Old October 4th 06, 06:26 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Call macro stored in Excel workbook from Outlook's macro

Am Tue, 3 Oct 2006 10:39:02 -0700 schrieb Gvaram:

Sorry, more I donīt know about that. Maybe itīs better you ask in an Excel
group.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Michael,
I read this help topic but had some problems - in outlook I wrote:
Excel.Application.run("C:Test.xls!GetDataFromMail" ,"aaaaa") , but it

coused
error "The macro 'C:\Test.xls!GetDataFromMail' could not be found."

I'd like to describe the whole process in detailes to make it clear:
My target is to initiate macros in excel file when Outlook receives a new
mail . For this purpose I wrote in "ThisOutlookSession" following Sub:

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim MyMeil As Outlook.MailItem
Dim intInitial As Integer
Dim intFinal As Integer
Dim strEntryID As String
Dim intLength As Integer
intInitial = 1
intLength = Len(EntryIDCollection)
intFinal = InStr(intInitial, EntryIDCollection, ",")
strEntryID = Strings.Mid(EntryIDCollection, intInitial, (intLength -
intInitial) + 1)
Set MyMeil = Application.Session.GetItemFromID(strEntryID)
If MyMeil.Attachments.Count 0 Then
If Right(MyMeil.Attachments.Item(1).FileName, 4) = ".xls" And
InStr(1, MyMeil.Subject, "App - ") 0 Then
'!!!!!!???? Call ??????????.GetDataFromMail(strEntryID) ' HERE IS MY

PROBLEM
MyMeil.UnRead = False
MyMeil.FlagIcon = olBlueFlagIcon
MyMeil.Save
Else: End If
Else: End If
End Sub

With this Sub I'm getting EntryID of recently received mail message.
On the other hand, in Excel file "C:\Test.xls" (which is already open) I
have another Sub which opens mailitem's attachment (I know EntryID from

Sub
provided above), copies it in one of it's sheets and then begins

processing
of data provided the

Sub GetDataFromMail(MailItemID as string)
Dim Attach As Outlook.Attachments
Dim myItem As Outlook.MailItem
Set myItem = Outlook.Application.Session.GetItemFromID(MailItem ID)
Set Attach = myItem.Attachments
Attach.Item(1).SaveAsFile ("C:\Book1200.xls")
Workbooks.Open Filename:="C:\Book1200.xls"
Sheets("Data").Select
Cells.Select
Selection.Copy
Windows("Test.xls").Activate
Sheets("DataProcessing").Select
Cells.Select
ActiveSheet.Paste
Windows("Book1200.xls").Activate
ActiveWindow.Close SaveChanges:=False
Windows("Test.xls").Activate
Range("A1").Select
Call DataProcessing 'This is another function in

Excel
Kill ("C:\Book1200.xls")
Else: End If
End Sub

Individually, both Subs are functioning well.
So, the target is to call "GetDataFromMail" from "Application_NewMailEx",

so
that new mail with the special excel file attachments must be processed
automatically.

Please help me to do this or tell me other solution...

"Michael Bauer [MVP - Outlook]" wrote:

Am Mon, 2 Oct 2006 09:56:02 -0700 schrieb Gvaram:

Please read the VBA help for the Application.Run function, thereīs also a
sample. As I understand it, you donīt need to open the workbook, but need
the Excel Application object.

Calling Outook VBA methods from outside isnīt documented, i.e. it works

for
the time being but you canīt rely on that. And thereīs no reason that it
must work for any other application, too.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I tried "Run" but there is the same result.
I don't know exactly, but I think the problem is in the way I'm

connecting
to the excel file. I tried:
1. GetObject("C:\Test.xls")
2. Excel.Application.Workbooks.Open("C:\Test.xls")

I don't know is there any other way to open excel file and call function
stored there? Logically, if excel macro can call outlook macros, Outlook
should do the same also - both of them are microsoft products and use

VBA.
But how???

Pleeease help....

"Michael Bauer [MVP - Outlook]" wrote:

Am Sun, 1 Oct 2006 14:16:01 -0700 schrieb Gvaram:

The Excel Application object knows a Run method. Probably that helps.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I'd like to run macro function "ExcelTestMacro" stored in

"C:\Test.xls"
(which is already open), when the new mail massage comes.

I can call macro in Outlook from Excel easily for example by :
Call ",
"Test","C:\test.xls")

But I could not call Excel macro from Outlook that way.
I allowed access to Visual basic Project and tried:
Set MyExBook = Excel.Application.Workbooks.open("C:\Test.xls")
call MyExBook.ExcelTestMacro
but there appears Run-Time error 'Object does not support this

property
or
method'. Of course I'm doing something wrong...

Somebody please help and tell me what to do


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Outlook Alias info into an excel 2003 macro fidgitthedigit Outlook and VBA 4 May 31st 06 04:22 PM
Importing Outlook Alias into an Excel 2003 macro fidgitthedigit Outlook - General Queries 2 May 30th 06 02:11 PM
Macro to import Excel data to Tasks Patrix317 Outlook and VBA 2 May 2nd 06 06:32 PM
Excel macro to create e-mail in Outlook Web Access fitful_thought Outlook - General Queries 0 April 15th 06 10:23 AM
How do I call a stored procedure inside my sql with a vba script? Computer Newbie Outlook and VBA 1 March 14th 06 07:08 AM


All times are GMT +1. The time now is 06:30 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2025 Outlook Banter.
The comments are property of their posters.