Get file name for email body reference

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722
I wold like to reference the Active Workbook file name in the body of the email I am sending out from a button. The sentence is telling people to go to a network location and lookup the name of a file. This is being placed in a worksheet that will be used by many different people. I only need to capture the file name, not the location.

Thanks in advance.
 

Some videos you may like

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Guitarde

Board Regular
Joined
Mar 18, 2003
Messages
238
Just use this code to add it into your button code:
vName = ActiveWorkbook.Name
 

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722
Variable not defined???

I put your code under the Dim statements in the module. Then I added & vName outside the quotes in the sentence. I got the error message mentioned above.

the code looks like:

Under the Dim statements I added
vName = ActiveWorkbook.Name


.body = "Dear "
"Please go to this location blah blah " & vName

What is wrong?
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Did you "Dim vName As String"?? Please post all your code.

I'd assume off hand (without seeing your code) at the top of your code you have 'Option Explicit' and that means you must declare all your variables.
 

justme

Well-known Member
Joined
Aug 26, 2002
Messages
722

ADVERTISEMENT

You were right.

Thanks.

This project is almost done!
 

Guitarde

Board Regular
Joined
Mar 18, 2003
Messages
238
First declare the variable

DIM vName as string

then

vName = ActiveWorkbook.Name
 

Watch MrExcel Video

Forum statistics

Threads
1,122,223
Messages
5,594,908
Members
413,952
Latest member
JGer

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