LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Open Files via InputBox - thx

Now it works. Many thanks!

Maria

-----Original Message-----
sName contains a value like "C:\Myfolder\MyFile.xls"

I provided a variable that holds a reference to the newly

opened file

Dim sName as String
Dim rng as Range
set rng = ActiveCell
chDrive "C"
ChDir "C:\Myfolder"
sName = Application.GetOpenfileName()
if sName < "False" then
set bk = Workbooks.Open(sName)
else
exit sub
End if

rng.Value = bk.Sheets("Hourly Data") _
.Range("CU1").Value

or if you need the filename, after opening:

sName = bk.name

also when the workbook is opened, it will be the

activeworkbook unless you
do something to make it not the activeworkbook.


--
Regards,
Tom Ogilvy


"Maria" wrote in

message
...
Thank you, Tom!
Now I have problems adressing the workbook. I tried the
following:

ActiveCell.Value = (Workbooks(sName).Sheets("Hourly
Data").Range("CU1").Value)

This produces a run time error - what can I do?
Thanks for your help again ...

Maria

-----Original Message-----
use the file open dialog

Dim sName as String
chDrive "C"
ChDir "C:\Myfolder"
sName = Application.GetOpenfileName()
if sName < "False" then
set bk = Workbooks.Open(sName)
else
exit sub
End if

msgbox bk.Name & " has been opened"

--
Regards,
Tom Ogilvy

"Maria" wrote in

message
...
Hello there,

I would like to create an InputBox that gives the

user
the
possibility to decide which file to open - he/she

should
type in the whole path. Is that possible, and if it

is
how
am I going to do it? Then, if the macro should work

with
the open file, how can I adress it? (The files look

all
the same but have slightly different names and

different
data ...)

Thanks for your help!

Maria


.



.



 
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
emailing files from excel, the files will not go until I open up . joe New Users to Excel 2 September 18th 09 02:12 PM
how do I toggle between 2 open excel files and leave both open Big D in Brighton Excel Discussion (Misc queries) 1 November 6th 08 04:28 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
file open via IE hyperlink causes already open files to shrink and tile Marc Setting up and Configuration of Excel 0 May 4th 05 08:13 PM
Open Folder from inputbox Phil Floyd Excel Programming 1 June 28th 04 06:34 PM


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