PDA

View Full Version : VBA for workbook path sending in an email



kellie1
07-26-2016, 12:29 PM
I have found a lot of info but none specific for what I need. I need VBA code that will insert the current workbook path [which changes daily due to a date in the path] into an outlook email so I can send to numerous people. Example workbook path S:\coname\Shared\Customer Care\docs\Spreadsheet 07-26-2016.xlsm. I do not want to have to type the path into the code myself I want the code to find via the open workbook.

Thanks

rollis13
07-26-2016, 12:37 PM
If the workbook has already been saved then your code could be:

ThisWorkbook.path & "\" & Spreadsheet 07-26-2016.xlsm

kellie1
07-26-2016, 12:44 PM
the issue is that each day the date portion of the path changes so once I save there is a new path daily, therefore I cannot code in VBA the exact path. I need the code to use the path from within the document.

rollis13
07-26-2016, 01:29 PM
To be precise, maybe you mean "the name of the file changes every day", not the path !!??

So your code could be:

"S:\coname\Shared\Customer Care\docs\" & ThisWorkbook.Name & ".xlsm"

or:

ThisWorkbook.path & "\" & ThisWorkbook.Name & ".xlsm"