Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forcing a Read Only Filename Zee[_2_] Excel Discussion (Misc queries) 10 September 24th 08 01:22 AM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Why is my Excel spreadsheet's sorting not being remembered? LisaSellsBabyCloths Excel Discussion (Misc queries) 0 July 2nd 05 09:29 PM
Copy one spreadsheet into another without activating second spreadsheet's user form P Cheek Excel Programming 3 July 23rd 03 06:26 PM


All times are GMT +1. The time now is 04:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"