Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default macro that opens file named in cell doesnt work

I wrote a macro that should open file with the name specified in cell
B8. It worked well yesterday but today I opened the file and the macro
doesnt work at all.

Could anyone tell whats wrong with the code.

Here it is the code:

Sub Import()

Sheets("Instruction").Select
Range("B8").Select
filetext = Selection.Value & ".xls"
directory = ".\"
Workbooks.Open directory & filetext

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default macro that opens file named in cell doesnt work

Try setting directory to the full path.
--
Gary''s Student - gsnu2007a


"Illuminati" wrote:

I wrote a macro that should open file with the name specified in cell
B8. It worked well yesterday but today I opened the file and the macro
doesnt work at all.

Could anyone tell whats wrong with the code.

Here it is the code:

Sub Import()

Sheets("Instruction").Select
Range("B8").Select
filetext = Selection.Value & ".xls"
directory = ".\"
Workbooks.Open directory & filetext

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default macro that opens file named in cell doesnt work

On 15 Lis, 12:15, Gary''s Student
wrote:
Try setting directory to the full path.
--
Gary''s Student - gsnu2007a


But I need this macro to open file from folder that the file with
macro is.
Btw, I have tried to put the name of the folder but it still doesn't
work.
It works when I put the exact path of the file with the name (not
reffering to the cell).

Please help, I have tried to modify the code and put sth like this:
Workbooks.Open Filename:= _
".\" & Range("B8").Value & ".xls"
But the error is still the same:
run-time error '1004'
Reply
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
Formula doesnt work when copy in different cell Mat Excel Discussion (Misc queries) 3 April 20th 07 08:34 PM
File opens with Enable or Disable Macro animalfriend7 Excel Discussion (Misc queries) 1 November 8th 06 04:29 PM
macro from excel 97 that doesnt work in excel 2003 (help) [email protected] Excel Discussion (Misc queries) 2 May 16th 06 03:01 PM
My first macro - doesnt work - function not recognised James Cornthwaite Excel Worksheet Functions 2 May 14th 06 05:13 PM
Assign Macro to button in Excel doesnt work Any ideas? Mike@Becketts Excel Discussion (Misc queries) 2 December 20th 04 02:47 PM


All times are GMT +1. The time now is 02:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"