VB .SaveAs

P

Paul

I'm trying to send an Excel file as an attachment via Outlook, which works.
But I would like the file name to relate to two different cells, i.e. E6 and
G6, with a space in between. I have got the subject to relate to one of these
cells and I was hoping it would be as straight forward as that was, but alas
I'm here asking for help.
 
P

Paul

I've just sorted this now, so don't panic - just in case anyone else has the
same problem this is what I did:

..SaveAs (Range("E6") & (" ") & Range("E8") & (".xls"))
 
B

Beth Melton

I see you found a solution to your question but why not provide you
with some type of response anyway? :)

Since the Range refers to the active worksheet you may want to be more
explicit in defining which worksheet to use to obtain the information.
It's also best to use variables to for something like this - it's not
only a little more efficient but they come in handy if you need to do
any troubleshooting. It use something like the following:
'--------start
Dim strFirstPart As String
Dim strSecondPart As String
Dim strFileName As String
strFirstPart = Sheets("Sheet1").Range("E6")
strSecondPart = Sheets("Sheet1").Range("E8")
strFileName = strFirstPart & " " & strSecondPart & ".xls"

ActiveWorkbook.SaveAs strFileName
'-------finish

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
Top