ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   content on textbox within userform (https://www.excelbanter.com/excel-programming/370392-content-textbox-within-userform.html)

sverre

content on textbox within userform
 
Hi,

ChDir "L:\Atla"
Workbooks.OpenText Filename:="L:\Atla\week32.xls"

I would like to replace the filename above with the values of three
textboxes which are within a userform. This should happen when I click "ok"
in the userform. Name of userform is newweek and name of textboxes are file1,
file2 and file3

reason is that there are new weeks and therefore new files...

Is it possible to do something with the L above? I mean you can map the disk
with something else than L depending on user.

many thanks
Sverre

Tom Ogilvy

content on textbox within userform
 
With Newweek
s = "L:\" & .file1.text & "\" & .file2.text & "\" & .file3.text &"\"
End with
chdrive "L"
chdir s
workbooks.Open "Week32.xls"

is one interpretaton

Another would be that you want to open 3 files listed in the textboxes
Dim bk1 as Workbook, bk2 as Workbook, bk3 as Workbook
chDrive "L"
chdir "L:\Atla"
With Newweek
set bk1 = workbooks.open( .file1.text)
set bk2 = Workbooks.open( .file2.text)
set bk3 = Workbooks.open( .file3.text)
End with

You show the extension as being .xls, so I would use the Open method rather
than open text if this indicates they are excel files.

--
Regards,
Tom Ogilvy


"sverre" wrote:

Hi,

ChDir "L:\Atla"
Workbooks.OpenText Filename:="L:\Atla\week32.xls"

I would like to replace the filename above with the values of three
textboxes which are within a userform. This should happen when I click "ok"
in the userform. Name of userform is newweek and name of textboxes are file1,
file2 and file3

reason is that there are new weeks and therefore new files...

Is it possible to do something with the L above? I mean you can map the disk
with something else than L depending on user.

many thanks
Sverre


sverre

content on textbox within userform
 
As always an excellent answer that works immediately!
Many thanks Tom!
Sverker

"Tom Ogilvy" skrev:

With Newweek
s = "L:\" & .file1.text & "\" & .file2.text & "\" & .file3.text &"\"
End with
chdrive "L"
chdir s
workbooks.Open "Week32.xls"

is one interpretaton

Another would be that you want to open 3 files listed in the textboxes
Dim bk1 as Workbook, bk2 as Workbook, bk3 as Workbook
chDrive "L"
chdir "L:\Atla"
With Newweek
set bk1 = workbooks.open( .file1.text)
set bk2 = Workbooks.open( .file2.text)
set bk3 = Workbooks.open( .file3.text)
End with

You show the extension as being .xls, so I would use the Open method rather
than open text if this indicates they are excel files.

--
Regards,
Tom Ogilvy


"sverre" wrote:

Hi,

ChDir "L:\Atla"
Workbooks.OpenText Filename:="L:\Atla\week32.xls"

I would like to replace the filename above with the values of three
textboxes which are within a userform. This should happen when I click "ok"
in the userform. Name of userform is newweek and name of textboxes are file1,
file2 and file3

reason is that there are new weeks and therefore new files...

Is it possible to do something with the L above? I mean you can map the disk
with something else than L depending on user.

many thanks
Sverre



All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com