One Macro to open various files...need to specify

  • Thread starter Thread starter sosteffo
  • Start date Start date
S

sosteffo

I need a line my my macro that takes the value from a cell/box/form an
then opens that file.


for example.....i have a macro that autoformats a report in a specifi
way, the problems is when i run the report the name of the spool fil
changes i.e spool 55225 will change to 55228 when i run a new report
 
Workbooks.Open FileName:="c:\Temp\"
sheets("Sheet1").range("a1").value


or

sFile$ = ="c:\Temp\" & sheets("Sheet1").range("a1").value
Workbooks.Open FileName:=sFil
 
this doesn't appear to work, the replacement line is highlighted red,
indicating some sort of error
 
oops typo to many =

I have assumed that cell a1 has a file name in it - no drive or path

replace "c\temp\" with drive and path for your file location if a1 ha
full path as well as file name then

Workbooks.Open FileName:="c:\Temp\"
sheets("Sheet1").range("a1").value


or

sFile$ ="c:\Temp\" & sheets("Sheet1").range("a1").value
Workbooks.Open FileName:=sFile




if a1 has full path as well as file name then use this code


Workbooks.Open FileName:=sheets("Sheet1").range("a1").valu
 
thanks.....works a treat

problem is im opening a word file in excel, using the way shown above
the file is opened automatically and doesn't prompt the "text import
wizard" which would normally appear when i open a text doc, this is
what my macro is based around.
 
Back
Top