![]() |
Activate a workbook
Hi
I have a macro that enables user to open multiple workbooks or select csv file which is imported into excel (but not saved as xls file). The path of each opened file is stored in an array as string (it's 6x6 dimension array). How can I than use that string (the path) to activate that specific file. So for instance msPathArray(1,6) stores a string "C:\my files\testfiles.csv" which is a path to a file that is already opened in excel. How can I activate that file? Kind regards |
Activate a workbook
this is conceptual, since i don't know what your code looks like. so i built
a little test macro, maybe it will help: Sub test() Dim mspatharray() As String Dim fpath As Variant Dim fname As String ReDim mspatharray(6, 6) mspatharray(1, 6) = "C:\my files\testfiles.csv" fpath = Split(mspatharray(1, 6), "\") fname = fpath(UBound(fpath)) Worksheets(fname).Activate End Sub -- Gary "IgorM" wrote in message ... Hi I have a macro that enables user to open multiple workbooks or select csv file which is imported into excel (but not saved as xls file). The path of each opened file is stored in an array as string (it's 6x6 dimension array). How can I than use that string (the path) to activate that specific file. So for instance msPathArray(1,6) stores a string "C:\my files\testfiles.csv" which is a path to a file that is already opened in excel. How can I activate that file? Kind regards |
Activate a workbook
sorry, this should be the last line
workbooks(fname).Activate Sub test() Dim mspatharray() As String Dim fpath As Variant Dim fname As String ReDim mspatharray(6, 6) mspatharray(1, 6) = "C:\my files\testfiles.csv" fpath = Split(mspatharray(1, 6), "\") fname = fpath(UBound(fpath)) workbooks(fname).Activate End Sub -- Gary "IgorM" wrote in message ... Hi I have a macro that enables user to open multiple workbooks or select csv file which is imported into excel (but not saved as xls file). The path of each opened file is stored in an array as string (it's 6x6 dimension array). How can I than use that string (the path) to activate that specific file. So for instance msPathArray(1,6) stores a string "C:\my files\testfiles.csv" which is a path to a file that is already opened in excel. How can I activate that file? Kind regards |
All times are GMT +1. The time now is 07:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com