ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Path/File Access Error (https://www.excelbanter.com/excel-programming/370507-path-file-access-error.html)

Geetha[_2_]

Path/File Access Error
 
Hi,

I get an Error message saying "Path/File Access Error" when i try
to create a new worksheet in a macro. The same macro works fine on my
machine, and we tested in 3-4 other machines. It fails only on a
particular machine. following is the code sample that causes the
problem.

Dim Sheet As Worksheet
Set Sheet = Sheets.Add(Type:=ThisWorkbook.Path & "\Report.xlt")

where Report.xlt is a template file that is stored in the same location
as the Excel file itself. Can anyone please help me figure out what
might be wrong. The code fails even when I create the worksheet without
using a template("Report.xlt). That is by using the following code

Dim Sheet As Worksheet
Set Sheet = Sheets.Add

Thanks.
Geetha


NickHK

Path/File Access Error
 
Geetha,
I can't duplicate your error with a variety of bad paths etc.
What does ThisWorkbook.Path evaluate to ?
Something strange about the permissions on that folder ?

NickHK

"Geetha" wrote in message
oups.com...
Hi,

I get an Error message saying "Path/File Access Error" when i try
to create a new worksheet in a macro. The same macro works fine on my
machine, and we tested in 3-4 other machines. It fails only on a
particular machine. following is the code sample that causes the
problem.

Dim Sheet As Worksheet
Set Sheet = Sheets.Add(Type:=ThisWorkbook.Path & "\Report.xlt")

where Report.xlt is a template file that is stored in the same location
as the Excel file itself. Can anyone please help me figure out what
might be wrong. The code fails even when I create the worksheet without
using a template("Report.xlt). That is by using the following code

Dim Sheet As Worksheet
Set Sheet = Sheets.Add

Thanks.
Geetha





All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com