XL doesn't like my path?

  • Thread starter Thread starter davegb
  • Start date Start date
D

davegb

I'm trying to tell XL which workbook to use:

Set wbOrig = H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Base\Abuse in
Care original.xls

but it doesn't like my backslash. I searched in the NG, but couldn't
find a similar example. So how do I tell it the path and workbook name?

Thanks!
 
If wbOrig is a string, then you don't need Set:

wbOrig _
= "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Base\Abuse in Care original.xls"

And you need double quotes around the string.

If wbOrig is a workbook object:

Dim OrigName as string
dim OrigWkbk as workbook 'I like more info in the variables

OrigName _
= "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Base\Abuse in Care original.xls"

set OrigWkbk = workbooks.open(filename:=origname)
 
set wbOrig = Workbooks.Open(filename:="H:\AllDocs\CFSR PIP DD\SFY 06
Q1\Records Base\Abuse in
Care original.xls")
 
Or if it is already open
set wbOrig = Workbooks("H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records
Base\Abuse in Care original.xls")
 
i'll just use something like this:

dim fPath as string
dim fName as string

fPath = "N:\My Documents\Excel\"
fName = fName = "Abuse in Care original.xls"

Workbooks.Open Filename:=fPath & fName
 
If it's already open, you can't have the path:

set wbOrig = Workbooks("Abuse in Care original.xls")
 
Dave said:
If wbOrig is a string, then you don't need Set:

wbOrig _
= "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Base\Abuse in Care original.xls"

And you need double quotes around the string.

If wbOrig is a workbook object:

Dim OrigName as string
dim OrigWkbk as workbook 'I like more info in the variables

OrigName _
= "H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records Base\Abuse in Care original.xls"

set OrigWkbk = workbooks.open(filename:=origname)

Thanks everyone! I should have mentioned that wbOrig is a workbook
object. Got it worked out!
 
Back
Top