Saved excel macro not availiable while opening a spreadsheet through an outlook form

N

Neal Millerschoen

I have a saved macro in excel that formats my data gathered from an
outlook form. When the form is received in email i created a button
to export the form into excel. When the excel spreadsheet opens and
the user hits "Ctrl+Z" to run the saved macro, nothing happens. My
macro isnt avalible. Now if I open the same spreadsheet through
windows explorer by double clicking the excel file, excel opens and my
macro is availiable. So there has to be something wrong with my code
for the outlook button that doesn't allow the PERSONAL.XLS to access
my saved macro when I open excel through outlook.

Now I have tried opening up excel twice through my code in outlook.
It opens my form and personal.xls, but they run in two seperate
instances of excel (2 excel programs running in the taskbar). And i
try running my macro on my form spreadsheet and still doesn't work.
Is there a way to open the personal.xls as a worsheet within my form
excel spreadsheet? (like when you unhide the personal.xls to edit
macros in excel) which will give me access to my macro that is saved
in the personal.xls?
Here is my code for the command button on the form in outlook:

sub cmdNew_Click()
strname = item.Subject
Item.SaveAs "C:\download\" & strname & ".xls", olXLS
Set myNameSpace = Application.GetNameSpace("MAPI")
Set xlApp = Item.Application.CreateObject("Excel.Application")
xlApp.Workbooks.Open("C:\download\PIR.xls")
Set xlBook = xlApp.ActiveWorkbook
Set xlSheets = xlBook.Worksheets
Set xlSheet = xlBook.Sheets(1)
xlSheet.Activate
xlApp.Application.Visible = True
end sub

the code works opens excel fine just can't run a saved macro on the
sheet.

Thanks,
Neal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top