Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Macro - I want to past filename into cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
a924fan@yahoo.com - 22 Sep 2007 18:20 GMT
MACRO --- I have:
NewFileNumber = Application.GetOpenFilename(FileFilter:="All Files
(*.*),*.*", Title:="Select a HEX file to import")
Open NewFileNumber For Input As #1

If filename is C:/temp.txt, I want to past that to a cell. I can copy
and past the content of variable 'NewFileNumber' if I knew how to copy
the content of 'NewFileNumber' . It is probaably easy to do but I just
don't know how to do it. Research is drawing a blank. TIA.
Dave Peterson - 22 Sep 2007 18:33 GMT
You can just plop that variable's contents directly into a cell:

Dim NewFileNumber as variant
NewFileNumber = Application.GetOpenFilename(FileFilter:="All Files (*.*),*.*", _
                   Title:="Select a HEX file to import")
if newfilenumber = false then
 'user hit cancel
 exit sub '???
end if

worksheets("sheet1").range("A1").value = newfilenumber

'rest of your code
Open NewFileNumber For Input As #1

> MACRO --- I have:
> NewFileNumber = Application.GetOpenFilename(FileFilter:="All Files
[quoted text clipped - 5 lines]
> the content of 'NewFileNumber' . It is probaably easy to do but I just
> don't know how to do it. Research is drawing a blank. TIA.

Signature

Dave Peterson

a924fan@yahoo.com - 22 Sep 2007 22:57 GMT
Thanks a million Dave, worked great!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.