Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ira Ira is offline
external usenet poster
 
Posts: 18
Default 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!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ira Ira is offline
external usenet poster
 
Posts: 18
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run time error 1004 Object defined error [email protected] Excel Programming 1 May 15th 07 03:31 AM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 03:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"