Run a macro when file is opened and display alerts

Devon Hill

New Member
Joined
Aug 6, 2002
Messages
28
Hi everybody. I'm looking for some code that will automatically start a macro once the file is opened (or at least after you click the enable macros button).

I also need help on this: I'm using this code to send an email:

ActiveWorkbook.SendMail Recipients:=Range("A1"), _
Subject:="PVR Data"
End Sub

I would like the display alert message that comes up asking me whether I want to send the email to automatically click on yes. I tried using the application.display alerts = False, but it didn't work....I also tried other applications, but none seem to work either. Any ideas? Thank you in advance.
This message was edited by Devon Hill on 2002-08-13 14:12
This message was edited by Devon Hill on 2002-08-13 14:13
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hiya

Email and 101 trick VBA Codes are very well documented in seach on this board, well worth a look, you read a few and get arround you issues here/

I would add a special sub routeen called Auto_Open()
' Your code here
'Suggets just call email sub
' IE code line

Call Jack_Email


End Sub

This example will call Jack_Email or whatever you called the section of VBA Sub routeen

HTH
 
Upvote 0
I've been looking a lot on this board, but I can't seem to find the answers to my questions.

I don't really understand what you mean by Call Jack_email. I don't understand where that is referenced to....I'm new at this, so could you please break it down a little better. Thank you very much.
 
Upvote 0
Hi Devon Hill

Sorry Jacks at it again, when i VBA i call everythink Jack, people are getting used to this sorry i must have mislead you, let me expalin a bit better [again sorry mate]

Jack_Mail was reference to you email code so instead of Jack call the name of your sub routeen in the Auto_Open sube routeen

ie

Sub Auto_Open()

Call DevonHills_code

Sub DevonHills_Code()
ActiveWorkbook.SendMail Recipients:=Range("A1"), _
Subject:="PVR Data"
End Sub

This when put into a module will make two subs and one will activate when enable macros is clicked thus running your code to email.

If disable is called no email.

I tnt to not clog teh auto_open and use call to other subs, make easier if you call more than one.

Hope thats a little cleared, i have used DEvonHills_Code to replace Jack_Email, just a name i cave it as your was missing.

HTH
 
Upvote 0
Thank you very much Jack. That code works great.

Does anybody have any ideas at all on how to bypass the alert message when sending the email?
 
Upvote 0
Hi

My pleasure to help - from the heart

Soory i do not know how to bypass this one, i kinda never want to, ill check or someone in VBA better than i might.

Take care,

Jack
 
Upvote 0

Forum statistics

Threads
1,226,727
Messages
6,192,686
Members
453,746
Latest member
Bruce at Pubdarts

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top