VBa Code Did't Open Workbook

Closed
azmiismail Posts 17 Registration date Thursday 3 March 2011 Status Member Last seen 20 July 2011 - 20 Jul 2011 à 02:06
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 22 Jul 2011 à 17:33
Hello,

I'm having a major headache in figuring out why the VBA code which I'm applying at my office computer seems to work perfectly but fail to work at my home computer.

The code is simple,

Sub OpenT1()
Workbooks.Open ("C:\Users\azmi\Documents\n.xls")
End Sub

n.xls is my file name
I keep getting error 1004 message , file could not be found.
I'd checked,double checked and triple checked the file locations,spelling and so on but could not find any error.

Can somebody help me out

Thanks
Related:

1 response

smd_excel Posts 27 Registration date Saturday 18 April 2009 Status Member Last seen 22 November 2012
20 Jul 2011 à 02:29
Capture the file name and location i.e. in variable

file_path = Sheets("sheet1").Cells(1, 2)
file_name = Sheets("sheet1").Cells(2, 2)

Workbooks.Open Filename:=file_path & file_name
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
22 Jul 2011 à 17:33
What is difference if I hard code the path or get it via variable ?