Log in

View Full Version : Excel Visual Basic Code...


Rai86
18-03-11, 12:27 PM
Anyone any good at it?


:oops:

Davadvice
18-03-11, 12:35 PM
ye, what are you looking to find out?

a good place is VBFORUMS.com

drop up your code and i will see what i can do

Dav

Rai86
18-03-11, 12:43 PM
I am trying to get it to send an email to a specific email address with the speadsheet attached

I can get it to bring up and email with it attached, but i have never done this before and thats about as far as i can get without any notes or help :(

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 18/03/2011 by Rachel Morris
'
'
Range("P30").Select
Application.Dialogs(xlDialogSendMail).Show
End Sub

I added in:

' Create a new email object

email.Subject = "Text"
email.Body = "Text"
email.From = "USER <EMAILADDRESS>"
email.AddTo "ADMIN","EMAIL ADDRESS"


But doesnt like that. And its all a bit futher than my basic knowledge goes :oops:

custard
18-03-11, 12:57 PM
beyond me.. i tend to record the macro and then chop it about to suit...

Davadvice
18-03-11, 01:45 PM
I am trying to get it to send an email to a specific email address with the speadsheet attached

I can get it to bring up and email with it attached, but i have never done this before and thats about as far as i can get without any notes or help :(

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 18/03/2011 by Rachel Morris
'
'
Range("P30").Select
Application.Dialogs(xlDialogSendMail).Show
End Sub

I added in:

' Create a new email object

email.Subject = "Text"
email.Body = "Text"
email.From = "USER <EMAILADDRESS>"
email.AddTo "ADMIN","EMAIL ADDRESS"


But doesnt like that. And its all a bit futher than my basic knowledge goes :oops:


change the File extention of the attachment from DOC to XLS (not able to upload xls files) if you open the file then navigate to VB you will see 2 modules ones a BAS file and the other is a CLS file.

the line OL.SendMessage "EMAIL@EMAIL.com", "TEST", "TEST123"

if you add a file name to the end like this
OL.SendMessage "EMAIL@EMAIL.com", "TEST", "TEST123", "c:\TESt.txt"

then it will send the attachment as well.

if you want to know how it works in detail give me a shout and i will do my best.

cheers
Dav
8685

Rai86
18-03-11, 02:04 PM
Brilliant thank you, i will give it a go

mikerj
18-03-11, 02:44 PM
Have a look here (http://www.rondebruin.nl/sendmail.htm)

DarrenSV650S
18-03-11, 04:17 PM
http://images.icanhascheezburger.com/completestore/2008/12/29/128750802820224556.jpg