![]() |
Find filename of open file
I've tried, and failed, to successfully open a template as an xlt file
(rather than xls) so I'm trying a different method to achieve what I need. My problem is this. Having opened a couple of files, I want to activate a specific one. Based on template filename.xlt, the workbook _should_ be filename1.xls, but this is not necessarily going to be the case. How can I determine the filename of the open file? I can't use Dir as the file hasn't been saved at this point. Any ideas? Ian |
Find filename of open file
Sub WhoAmI()
MsgBox (ActiveWorkbook.Name) End Sub -- Gary''s Student - gsnu2007h "Ian" wrote: I've tried, and failed, to successfully open a template as an xlt file (rather than xls) so I'm trying a different method to achieve what I need. My problem is this. Having opened a couple of files, I want to activate a specific one. Based on template filename.xlt, the workbook _should_ be filename1.xls, but this is not necessarily going to be the case. How can I determine the filename of the open file? I can't use Dir as the file hasn't been saved at this point. Any ideas? Ian |
Find filename of open file
Something like this will give you the names of all open workbooks...
Sub Test dim wbk as workbook for each wbk in workbooks msgbox wbk.name next wbk end sub -- HTH... Jim Thomlinson "Ian" wrote: I've tried, and failed, to successfully open a template as an xlt file (rather than xls) so I'm trying a different method to achieve what I need. My problem is this. Having opened a couple of files, I want to activate a specific one. Based on template filename.xlt, the workbook _should_ be filename1.xls, but this is not necessarily going to be the case. How can I determine the filename of the open file? I can't use Dir as the file hasn't been saved at this point. Any ideas? Ian |
Find filename of open file
Hi Gary
Apparently this will give me the name of the active workbook, but isn't what I need. With several files open, I want to return focus to a specific file for which I only have a partial name (eg filenameXX.xls where XX is unknown). Ian "Gary''s Student" wrote in message ... Sub WhoAmI() MsgBox (ActiveWorkbook.Name) End Sub -- Gary''s Student - gsnu2007h "Ian" wrote: I've tried, and failed, to successfully open a template as an xlt file (rather than xls) so I'm trying a different method to achieve what I need. My problem is this. Having opened a couple of files, I want to activate a specific one. Based on template filename.xlt, the workbook _should_ be filename1.xls, but this is not necessarily going to be the case. How can I determine the filename of the open file? I can't use Dir as the file hasn't been saved at this point. Any ideas? Ian |
Find filename of open file
Thanks, Jim.
I've not tested this yet, but it looks like it'll do what I need. I should be able to loop through the open workbooks until I find a match with the partial filename I have, then activate the matched workbook. Ian "Jim Thomlinson" wrote in message ... Something like this will give you the names of all open workbooks... Sub Test dim wbk as workbook for each wbk in workbooks msgbox wbk.name next wbk end sub -- HTH... Jim Thomlinson "Ian" wrote: I've tried, and failed, to successfully open a template as an xlt file (rather than xls) so I'm trying a different method to achieve what I need. My problem is this. Having opened a couple of files, I want to activate a specific one. Based on template filename.xlt, the workbook _should_ be filename1.xls, but this is not necessarily going to be the case. How can I determine the filename of the open file? I can't use Dir as the file hasn't been saved at this point. Any ideas? Ian |
Find filename of open file
Hi Jim
Works a treat, thanks. I still wish I knew why I couldn't OPEN the template instead of creating a NEW FILE based on it, but at least I have a workaround. Ian "Ian" wrote in message ... Thanks, Jim. I've not tested this yet, but it looks like it'll do what I need. I should be able to loop through the open workbooks until I find a match with the partial filename I have, then activate the matched workbook. Ian "Jim Thomlinson" wrote in message ... Something like this will give you the names of all open workbooks... Sub Test dim wbk as workbook for each wbk in workbooks msgbox wbk.name next wbk end sub -- HTH... Jim Thomlinson "Ian" wrote: I've tried, and failed, to successfully open a template as an xlt file (rather than xls) so I'm trying a different method to achieve what I need. My problem is this. Having opened a couple of files, I want to activate a specific one. Based on template filename.xlt, the workbook _should_ be filename1.xls, but this is not necessarily going to be the case. How can I determine the filename of the open file? I can't use Dir as the file hasn't been saved at this point. Any ideas? Ian |
All times are GMT +1. The time now is 03:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com