Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default returning filename in excel

In MS Word I used:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With

to obtain the filename of the active document. How can I do this in
Excel?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default returning filename in excel

Claud

To get the filename of the activeworkbook, use

sFileName=ActiveWorkbook.FullName

If you want to display the open dialog and then open a workbook

sFilename=Application.GetOpenFileName()
Workbooks.Open FileName:=sFileName

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS

"Claud Balls" wrote in message
...
In MS Word I used:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With

to obtain the filename of the active document. How can I do this in
Excel?


*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default returning filename in excel

ActiveWorkbook.Name

or

ActiveWorkbook.FullName

--
Regards

Juan Pablo González

"Claud Balls" wrote in message
...
In MS Word I used:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With

to obtain the filename of the active document. How can I do this in
Excel?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default returning filename in excel

Claud,

Check out the GetOpenFilename method in VBA help.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Claud Balls" wrote in message
...
In MS Word I used:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With

to obtain the filename of the active document. How can I do this in
Excel?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default returning filename in excel

One way:

strSourceFile = ActiveWorkbook.Name

or, if you want the path, too

strSourceFile = ActiveWorkbook.FullName




In article ,
Claud Balls wrote:

In MS Word I used:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With

to obtain the filename of the active document. How can I do this in
Excel?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
vlookup and filename returning same result on each sheet. RogueSwan Excel Discussion (Misc queries) 3 March 22nd 05 10:08 PM
Saving filename same as import filename Matt Excel Programming 4 February 24th 04 03:01 PM
Workbooks.Open(filename) : Returning err: Object reference not... (in VB.NET) bryan Excel Programming 2 January 20th 04 07:42 PM


All times are GMT +1. The time now is 10:33 AM.

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

About Us

"It's about Microsoft Excel"