XL doesn't like my path?

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!
 
D

Dave Peterson

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)
 
K

Kletcho

set wbOrig = Workbooks.Open(filename:="H:\AllDocs\CFSR PIP DD\SFY 06
Q1\Records Base\Abuse in
Care original.xls")
 
K

Kletcho

Or if it is already open
set wbOrig = Workbooks("H:\AllDocs\CFSR PIP DD\SFY 06 Q1\Records
Base\Abuse in Care original.xls")
 
G

Gary Keramidas

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
 
D

Dave Peterson

If it's already open, you can't have the path:

set wbOrig = Workbooks("Abuse in Care original.xls")
 
D

davegb

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top