path relativo a la hora de abrir o guardar un fichero.

Osasa54

New Member
Joined
Sep 10, 2002
Messages
31
Hola, tengo la siguiente linea de código, la cual me abre un fichero .xls:
Workbooks.Open Filename:="C:\Windows\base.xls"
el fichero de excel que yo tengo lo ejecuto desde "c:\windows\", y lo que me gustaría es saber como podría poner un path relativo al directorio en el que estoy trabajando. He probado con Workbooks.Open Filename:=".\base.xls", pero evidentemente no me lo coge.
Un saludo

Oscar
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hola Oscar,

Si comprendo su pregunta bien, creo que usted podría utilizar la propriedad .Path de objetos Workbook.

strSendero = Workbooks("Ventas").Path

o

strSendero = ActiveWorkbook.Path

luego puede hacer algo como

strSendero = strSendero & Application.PathSeparator
Workbooks.Open FileName:=strSendero & "Compras.xls"


Saludos,
 
Upvote 0

Forum statistics

Threads
1,223,942
Messages
6,175,544
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top