PDA

View Full Version : Macros in personal.xls execution based on different file names



Gabba
04-23-2009, 01:00 AM
Hi,
I've a macro code to separate the report into two separate reports.
This is done when the user open the attachment from the mail and use the short cut key.

My requirement is i've two set of macro codes (A,B) in VBA module.
Code A has to be executed when the active workbook name starts with file name Attendance and code B has to be executed when the file name starts with DAL.

Gabba
04-23-2009, 01:02 AM
To bring clarity on the first para (report separation), On execution of a macro, a Excel file will be splitted into two sheets.

GTO
04-23-2009, 04:05 AM
Could you show us what you have so far?

Mark

Gabba
04-23-2009, 04:10 AM
PFA two files - Input file and output file. Due to attachment restriction,
i will attach the output file in next thread.

Gabba
04-23-2009, 04:11 AM
PFA the output file

mdmackillop
04-23-2009, 11:33 AM
Something like
Sub CodeToRun()
If Left(Workbook.Name, 10) = "Attendance" Then Call CodeA
If Left(Workbook.Name, 3) = "DAL" Then Call CodeB
End Sub

Gabba
04-29-2009, 09:03 AM
Getting a run time error - 424 (object required)

I've placed the below code in module section.
If Left(Workbook.Name, 10) = "Attendance" Then Call codeA
If Left(Workbook.Name, 3) = "DAL" Then Call codeB


FYI - I've placed two sub programs in module. I've workbook open event code to trigger this.

Whenever i open an attachment and the file name matches with the above (attendance or DAL) the code will get executed.
Please see the attachment.

mdmackillop
04-29-2009, 10:25 AM
Hi Gabba,
You need to step through your code to determine what is causing the error.
In your example Workbook.Name has no value
Your worbook is not called third_test
Resolve these and the code will run.