content on textbox within userform

G

Guest

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
 
G

Guest

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.
 
G

Guest

As always an excellent answer that works immediately!
Many thanks Tom!
Sverker

"Tom Ogilvy" skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top