Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 18
Default Putting path and filename in a macro

I have a macro that I use that references several files
on a network. I'd like to use this spreadsheet as a
template and have the path and filename automatically
change to whatever the file is called. Example. I have
a file called \\FileShare\Excel\example.xls and I
reference that path in a macro. Now I want to open that
file and do a 'save as' and change the filename to
\\FileShare\Excel\example2.xls. Now I'd like to have it
automatically reflect the name change in the macro
without having to go into the VBA editor and manually
change the filename. Does anyone know if this is
possible?

Hope that makes sense.

Thanks
JC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Putting path and filename in a macro

Try inserting into and running from a saved workbook:

Sub Paths()
MsgBox ThisWorkbook.Name
MsgBox ThisWorkbook.Path
MsgBox ThisWorkbook.FullName
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"JC" wrote in message
...
I have a macro that I use that references several files
on a network. I'd like to use this spreadsheet as a
template and have the path and filename automatically
change to whatever the file is called. Example. I have
a file called \\FileShare\Excel\example.xls and I
reference that path in a macro. Now I want to open that
file and do a 'save as' and change the filename to
\\FileShare\Excel\example2.xls. Now I'd like to have it
automatically reflect the name change in the macro
without having to go into the VBA editor and manually
change the filename. Does anyone know if this is
possible?

Hope that makes sense.

Thanks
JC



  #3   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 18
Default Putting path and filename in a macro

Cool. How about if I am referencing that same file in
another worksheet? What I am doing is refreshing links
to all files (about 15 of them) from a macro that runs in
another file. If I change the name of the file I have to
manually change it in VBA. Is there a way to do this
dynamically?

Thanks,
JC
-----Original Message-----
Try inserting into and running from a saved workbook:

Sub Paths()
MsgBox ThisWorkbook.Name
MsgBox ThisWorkbook.Path
MsgBox ThisWorkbook.FullName
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"JC" wrote in

message
...
I have a macro that I use that references several files
on a network. I'd like to use this spreadsheet as a
template and have the path and filename automatically
change to whatever the file is called. Example. I

have
a file called \\FileShare\Excel\example.xls and I
reference that path in a macro. Now I want to open

that
file and do a 'save as' and change the filename to
\\FileShare\Excel\example2.xls. Now I'd like to have it
automatically reflect the name change in the macro
without having to go into the VBA editor and manually
change the filename. Does anyone know if this is
possible?

Hope that makes sense.

Thanks
JC



.

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
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Getting a filename into VBA and putting it into cells Babymech Excel Discussion (Misc queries) 2 February 27th 10 01:48 PM
Prevent Excel putting full filename in external links on update [email protected] Excel Discussion (Misc queries) 5 March 29th 07 08:42 PM
How do i display the Filename without the path? robert_manic Excel Discussion (Misc queries) 3 October 11th 06 05:47 PM
Excel 2K: Putting Filename & path in footer FinChase Excel Discussion (Misc queries) 1 March 14th 05 08:12 PM


All times are GMT +1. The time now is 02:11 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"