put path in as variable

  • Thread starter Thread starter Bruce Roberson
  • Start date Start date
B

Bruce Roberson

I need this sub to allow me to specify the path to the
file I want to open here so that no matter what the
current path is, it will find this file. It works in cases
where this path is already the current path, but the open
file fails if another folder is the active path.
But this sub refuses to do what I want it to do. It just
keeps insisting an object is required on the line where I
set path = "D:\....

If I remove the " ", then it highlights the "/" and says
something about expects a line number. I wish this thing
would learn to speak English for a change.


Sub Import()
Dim cRows As Long
Dim path As String
Set path = "D:\myfiles\data\ttax\"
Sheets("Import").Select
Application.Goto Reference:=("Importarea")
Selection.CurrentRegion.Clear
Range("A1").Select
Workbooks.Open Filename:="path" & "LUSE.WK1"

Thanks,


Bruce
 
Path is not an object it's a string
so you can't use SET

path="d:\data"

(officially it's LET path="d:\data" but contrary to SET VBA understands
if you leave it out so in practice nobody uses LET)



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Bruce,

Try removing the "Set" statement, no need for it with
a string object. path = "D:\myfiles\data\ttax\"
also path is a poor name as it is a member of several
classes, try myPath or something along those lines.

Dan E
 
Back
Top