VBA to read spreadsheet's filename?
Hi,
I'm a novice at Excel VBA and looking for a way to retrieve the filename (e.g. asdfasdf.xls) of the current spreadsheet. Is there a way to do this? Thanks Jon |
VBA to read spreadsheet's filename?
Jon,
Try something like Dim S As String S = ActiveWorkbook.Name ' or S = ThisWorkbook.Name Use FullName instead of Name if you want the full name (drive, folder, and file) of the file. -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com "Jon" wrote in message om... Hi, I'm a novice at Excel VBA and looking for a way to retrieve the filename (e.g. asdfasdf.xls) of the current spreadsheet. Is there a way to do this? Thanks Jon |
VBA to read spreadsheet's filename?
MsgBox ThisWorkbook.FullName
losmac Uzytkownik "Jon" napisal w wiadomosci om... Hi, I'm a novice at Excel VBA and looking for a way to retrieve the filename (e.g. asdfasdf.xls) of the current spreadsheet. Is there a way to do this? Thanks Jon |
VBA to read spreadsheet's filename?
Which is probably what Jon really would wanted but not what he asked for.
More details on my http://www.mvps.org/dmcritchie/excel/pathname.htm Page also has worksheet solutions as well as main emphasis on headers/footers.. Code in VBA Description VBA codeExample Full Name: Application.ActiveWorkbook.FullName D:\TestFolder\test.xls Path: Application.ActiveWorkbook.Path C:\MSOffice\Excel Filename: Application.ActiveWorkbook.Name test.xls Sheetname: application.activesheet.name Sheet1 --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "losmac" wrote in message ... MsgBox ThisWorkbook.FullName losmac Uzytkownik "Jon" napisal w wiadomosci om... Hi, I'm a novice at Excel VBA and looking for a way to retrieve the filename (e.g. asdfasdf.xls) of the current spreadsheet. Is there a way to do this? Thanks Jon |
All times are GMT +1. The time now is 12:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com