Help with 'easy' project.

Massey1337

New Member
Joined
Mar 8, 2009
Messages
17
Okay my dad has set me a project, apparently it's no more than 6 lines, but I can't get my head around it.
The idea is on an excel worksheet is to enter the name of the file and the data (user does this manually) then clicking the command button will refresh the worksheet, combine the contents of these 2 cells and save the file and e-mail the file to the same e-mail address every time.

My current code is:
Sub Button1_Click()
Dim fname As String
Dim MyDate
MyDate = Date
fname = Worksheets("Sheet1").Cells(3, 2)
fname = fname + MyDate
ActiveWorkbook.SaveAs fname

End Sub

I really need help on this, it's sending me round the bend, thanks.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Massey1337

New Member
Joined
Mar 8, 2009
Messages
17
Thanks for your help. :)
It currently saves the file as just the data, preferably I'd like the name that the user manually enters in front of the date.
e.g. Cell (3, 2) has Elliot Massey, file saves as 'Elliot Massey 21/03/2009.xls'
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
preferably I'd like the name that the user manually enters in front of the date.
e.g. Cell (3, 2) has Elliot Massey, file saves as 'Elliot Massey 21/03/2009.xls'

That's exactly what it does. Make sure that you enter something in B3 before running the macro.
 
Upvote 0

Massey1337

New Member
Joined
Mar 8, 2009
Messages
17
Ah thank you got it now, had it in C2. :)
I've also tried googling refreshing (recalculating) the worksheet, but again, I'm having no luck with my code.
I've looked through the e-mail function and I can't get it to work
I'm getting the error: Microsoft Office Outlook No profiles have been created. To create a new profile, use the mail icon in the Control Panel.
And: Run-time error '1004': Method 'SendMail' of object ' _Workbook' failed
I don't want to have to create a new profile to complete this.
This is my current code now:
Sub Button1_Click()
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim fname As String
fname = Worksheets("Sheet1").Cells(2, 3)
fname = fname & " " & Format(Date, "dd-mm-yy") & ".xls"
ActiveWorkbook.SaveAs fname
wb.SendMail "elliot_massey@hotmail.co.uk", _
"Attachment sent."
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If GetXLCol(Target.Column) = "G" Then
Calculate
End If
End Sub
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
I'm not sure what

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If GetXLCol(Target.Column) = "G" Then
Calculate
End If
End Sub

has to do with this but it belongs in the sheet's code module. Right click the sheet's tab, select View Code and place the code in there.

The e-mailing code works fine for me as you'll see if you check your Inbox - I sent it as an .xslm file as I'm using Excel 2007.
 
Upvote 0

Massey1337

New Member
Joined
Mar 8, 2009
Messages
17
Changed it to what you said, but I still get the no profiles have been created blah blah and Runtime error 1004 Application-defined or object-defined error
 
Upvote 0

Sanjeev1976

Active Member
Joined
Dec 25, 2008
Messages
348
Office Version
  1. 365
Platform
  1. Windows
Click on Microsoft Outlook from the programs and create a profile with your email id. Since if you send an email to any email id, excel will select the default profile set in Microsoft Outlook and send an email.
 
Upvote 0

Sanjeev1976

Active Member
Joined
Dec 25, 2008
Messages
348
Office Version
  1. 365
Platform
  1. Windows
Search the internet using Google or some other search engine for your respective email account
 
Upvote 0

Forum statistics

Threads
1,190,789
Messages
5,982,922
Members
439,807
Latest member
WXM86

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
Top