![]() |
run time error 1004
I have run time error 1004 while running a macro. It says Microsoft Office
Excel can not access the file. But file is there. Is anuthing wrong in the code? OutputFile = "C:\users\hz7fff\Desktop\Monthly Settlement\Monthly Output Files\" Report_Workbook = ActiveWorkbook.Name If (Left(Report_Workbook, 11) = "Settlement ") Then ActiveWorkbook.Names.Add Name:="Settlement_Data", RefersToR1C1:= _ "='Monthly Settlement Statement'!C1:C8" ActiveWorkbook.Names.Add Name:="Copy_Row", RefersToR1C1:= _ "='Monthly Settlement Statement'!RC1,'Monthly Settlement Statement'!RC2,'Monthly Settlement Statement'!RC4,'Monthly Settlement Statement'!RC8" Range("A1").Select ' Message = "Enter the year and month for the data just processed in YYYYMM format." Title = "FileName" Data_Date = InputBox(Message, Title) ' Save_File = "Settlement " & Left(Data_Date, 4) & "-" & Right(Data_Date, 2) & ".xls" Save_FullName = OutputFile & Save_File ''''''''''''''''''''''''''''''''''''''It stops here ActiveWorkbook.SaveAs Filename:= _ Save_FullName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False '''''''''''''''''''''''''''''''Please help! |
run time error 1004
On 1 Maj, 18:20, Ira wrote:
I have run time error 1004 while running a macro. It says Microsoft Office Excel can not access the file. But file is there. Is anuthing wrong in the code? OutputFile = "C:\users\hz7fff\Desktop\Monthly Settlement\Monthly Output Files\" Report_Workbook = ActiveWorkbook.Name If (Left(Report_Workbook, 11) = "Settlement ") Then * * ActiveWorkbook.Names.Add Name:="Settlement_Data", RefersToR1C1:= _ * * * * "='Monthly Settlement Statement'!C1:C8" * * ActiveWorkbook.Names.Add Name:="Copy_Row", RefersToR1C1:= _ * * * *"='Monthly Settlement Statement'!RC1,'Monthly Settlement Statement'!RC2,'Monthly Settlement Statement'!RC4,'Monthly Settlement Statement'!RC8" * * Range("A1").Select ' * * Message = "Enter the year and month for the data just processed in YYYYMM format." * * Title = "FileName" * * Data_Date = InputBox(Message, Title) ' * * Save_File = "Settlement " & Left(Data_Date, 4) & "-" & Right(Data_Date, 2) & ".xls" * * Save_FullName = OutputFile & Save_File ''''''''''''''''''''''''''''''''''''''It stops here * * ActiveWorkbook.SaveAs Filename:= _ * * * * Save_FullName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ * * * * ReadOnlyRecommended:=False, CreateBackup:=False '''''''''''''''''''''''''''''''Please help! Hi Check if the folder exists, I don't think it does. Use the code below to test if OutputFile is a valid path. OutputFile = "C:\users\hz7fff\Desktop\Monthly Settlement\Monthly Output Files\" Set fs = CreateObject("Scripting.FileSystemObject") If fs.folderexists(OutputFile) = False Then msg = MsgBox("The folder do not exists", vbCritical) Exit Sub End If Regards, Per |
run time error 1004
Thank you so much, Per. It works now. You are right, it was misspeled.
"Per Jessen" wrote: On 1 Maj, 18:20, Ira wrote: I have run time error 1004 while running a macro. It says Microsoft Office Excel can not access the file. But file is there. Is anuthing wrong in the code? OutputFile = "C:\users\hz7fff\Desktop\Monthly Settlement\Monthly Output Files\" Report_Workbook = ActiveWorkbook.Name If (Left(Report_Workbook, 11) = "Settlement ") Then ActiveWorkbook.Names.Add Name:="Settlement_Data", RefersToR1C1:= _ "='Monthly Settlement Statement'!C1:C8" ActiveWorkbook.Names.Add Name:="Copy_Row", RefersToR1C1:= _ "='Monthly Settlement Statement'!RC1,'Monthly Settlement Statement'!RC2,'Monthly Settlement Statement'!RC4,'Monthly Settlement Statement'!RC8" Range("A1").Select ' Message = "Enter the year and month for the data just processed in YYYYMM format." Title = "FileName" Data_Date = InputBox(Message, Title) ' Save_File = "Settlement " & Left(Data_Date, 4) & "-" & Right(Data_Date, 2) & ".xls" Save_FullName = OutputFile & Save_File ''''''''''''''''''''''''''''''''''''''It stops here ActiveWorkbook.SaveAs Filename:= _ Save_FullName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False '''''''''''''''''''''''''''''''Please help! Hi Check if the folder exists, I don't think it does. Use the code below to test if OutputFile is a valid path. OutputFile = "C:\users\hz7fff\Desktop\Monthly Settlement\Monthly Output Files\" Set fs = CreateObject("Scripting.FileSystemObject") If fs.folderexists(OutputFile) = False Then msg = MsgBox("The folder do not exists", vbCritical) Exit Sub End If Regards, Per |
All times are GMT +1. The time now is 10:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com