Error 53 At Open Filename For Output
Jun 2, 2009
I try to make a macro for saving an Excel sheet to a .CSV file with "@" as delimiter.
At the line "Open fname For Output As #fnum", the Error 53, "no file found" occurs.
The Excel-help is saying that if the file is not present, a new file will be made.
This error occurs now and then, How to proceed?
Full macro:
Sub SaveAsCSV()
Path = "O:actueel"
Fname1 = Path & Range("E2").Value & ".csv"
fname = Application.GetSaveAsFilename(Fname1, "CSV bestand (*.csv), *.csv", , "")
If fname = False Then
MsgBox "Macro Geannuleerd"
Exit Sub
End If
View 9 Replies
ADVERTISEMENT
Jan 23, 2008
I am trying to skip over any errors associated with the GetOpenFilename window, specifically where the Cancel button is selected, or no files selected. In the code below, I get an error "Object required" at the line shown every time this is run, even when the file path is valid and correct, and then the msgbox appears as a result of the On Error statement .
myExcelFilePath is dim Variant
On Error Resume Next
myExcelFilePath = Application.GetOpenFilename("Excel files (*.xls), *.xls", , "locate Report.xls....")
If myExcelFilePath Is Empty Or myExcelFilePath Is Null Then
View 9 Replies
View Related
Aug 6, 2013
I have a csv file named "BB31_2013-08-01". I would like to open this file via vba and this is not my only file. I also have another similar fileames such as "BB31_2013-08-08", therefore, I try to create some function like yyyy, mm & dd where I can modifie it easily for next file.
Here is my code:
VB:
'change weekly
yyyy = "2013"
mm = "08"
dd = "01"
Workbooks.Open Filename:= _
"C:Documents and Settings1314228DesktopTest ProgressBB31& yyyy &-& mm &-& dd.csv"
[Code] .....
View 3 Replies
View Related
Apr 14, 2009
Is there any solution to the fact that hyperlinks in excel with a # in filename wont open?
View 9 Replies
View Related
May 13, 2007
Below is the code that references a file to import = Jan.txt.
There are different files I want to import, using this macro.
However I have not been successful with creating a variable
and then creating a statement which requires me to input the filename that I want to import for the macro run.
With ActiveSheet.QueryTables.Add(Connection:="TEXT;U:Jan.txt", Destination _
:=Range("A1"))
View 6 Replies
View Related
Sep 23, 2013
My company has several users that access a file (File A) that has a macro in that opens another file on their F drive called TEST.XLS. The code (in File A) to do this is:
Workbooks.Open Filename:="F: est.xls"
Just recently this code has failed for some users but not others. For those where it failed I confirmed that they do indeed have the file located on drive F.
As a test, one of the users where the above code failed ran the macro recorder while opening the file (Test.xls) on their F drive. The recorder produced the following code:
Workbooks.Open Filename:="\companynetsta$jsmith est.xls"
It appears the code is failing because Excel is looking for a UNC path as opposed to a drive letter (F).
I prefer that the code that looks at the Drive letter F be used.
How can I get the following code to workWorkbooks.Open Filename:="F: est.xls" ....for all users that have an F drive?
View 6 Replies
View Related
Aug 1, 2008
I would like to create a macro to open a file in Excel 2007. My problem is that the filename changes often. After updates are made the filename is changed and the old file is moved to a backup folder. So, there is only one similar file in the folder
My filename is "RFQ Worksheet 7 29 2008.xlsx".
The path is "C:Documents and SettingsahaynijDesktop".
View 5 Replies
View Related
Mar 11, 2014
I have a Workbook "forecast.xlsx" and several Workbooks which have a individual Number in the Filename (E.g. "3960........xls", "3961.......xls etc.) in the same directory as "forecast.xlsx" + projects"
Now, I would like to browse through "forecast.xlsx" in column H, searching for hyperlinks. In Column H are these Projectnumbers located which are used in the filenames above. Whenever the Cell cointains a hyperlink, following should happen (that far i managed it by myself):
- Store the Cellvalue in a String Variable
- Go to the Directory this.workbook + projects
- browse this folder, searching for a File which contains the stored string in its filename
- open the file
- copy a range
- close file
- This.workbook.Activate
- follow the Hyperlink which has been stored as String before
- paste selection
- continue browsing through column H, looking for the next hyperlink.
I have a VBA which runs bugless, but it copies the wrong range, but to the correct destination.
See the code below:
Sub RESLT_INPUT_ALL()
Dim cell As Object
For Counter = 1 To 1000
Set cell = Worksheets("Projects overview").Cells(Counter, 8)
If cell.Hyperlinks.Count > 0 Then
[Code] ......
View 1 Replies
View Related
Aug 1, 2006
Am working on a procedure to open all files in a folder and copy some data from the files into another workbook (master). I have this piece of the code. However, I also need to get the filename (from which data was copied) and paste this into an adjacent cell in the master (so I know which file each data point came from).
View 8 Replies
View Related
May 26, 2007
I am trying to open a workbook with
Workbook.Open filename:="xxxxx"
The address in the xxxx is something like this "G:AnimalMammalZZZZGorillayyyy.xls"
The ZZZZZ portion is the result of an InputBox.
What is the syntax for placing the result of that InputBox in the middle of the address?
View 3 Replies
View Related
Apr 3, 2014
I have the following code which successfully opens the specified workbook and copies the values to the active workbook, but then gives an error on the line of extracting filename, and when extracting last author. However, the code works fine if I use 'getopenfilename'.
[Code]......
View 8 Replies
View Related
Feb 11, 2013
I'm on excel 2010 and I have a small group excel files I open everyday. Most of the files are static in name and location. I've got a macro created to open those files, which works fine with workbooks.open and the file path.
There are two report files I want to incorporate into my macro of workbooks to open. The files are created weekly and the files names have the following format: "Report Name (YYYY-MM-DD).xlsm". I don't want to use the file's last modified date because older files may get edited after the more recent ones are created. The files are also not always created on the same day, so the solution needs to be flexible enough to not refer to a specific day of the week or anything.
Macro open an excel file based on the latest date found in filename.
View 9 Replies
View Related
Jul 17, 2014
There are 2 macros in the workbook.
APlusB: Taking the marks of first subjects for all subjects. No correct output no any compile error.
Total: Getting compile error 1004.
View 4 Replies
View Related
Oct 23, 2008
The below code line is causing the workbook to debug then fail to open for 50% of users and i dont know why, has anybody got any ideas.
Could it be bacuase it cannot read the machines time or date ?
Code: If day is Sat or Sun, or if time is after 3pm it calls a macro.
Private Sub Workbook_Open()
If Weekday(Date) = 7 Or Weekday(Date) = 1 Or Time >= TimeSerial(15, 0, 0) Then
I cant test the machines its failing on as i'm working from home !
View 9 Replies
View Related
Feb 27, 2012
I recorded a macro to save a worksheet as a PDF file
It works fine, except when the PDF file is already open - Excel returns an error message and stops.
Can I use some error handling code to prevent the error, maybe bring up a msgbox and exit the sub at the point where the error occurs?
The part of the code where it stops is:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:UsersDaveDesktopTestingDemo List.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
View 2 Replies
View Related
Feb 21, 2013
Have some code in the workbook open event, which when I run when the workbook is already open works fine, however when triggered when the workbook is actually opened it fails on the first line.
Code:
Private Sub Workbook_Open()
Dim lngLastRow As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim X As Long
Dim Y As Long
'Define Worksheet
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets("Sheet3")
Sheets("Sheet1").Activate
View 2 Replies
View Related
Sep 6, 2009
This is what i am doing, i m trying to open file one after other in a folder, and process each of them for some information in it and then closing it without saving it. and looping through next.
Code runs great the first loop record, when it tries to get into loop second time, it breaks with error 1004: run time.
Workbook.Open failed...... I have no clue, as files are there folder is there and code runs the first time...
View 9 Replies
View Related
Aug 1, 2007
I'm using this simple code found on ozgrid to open all excel files in a folder...
Sub OpenAllWorkbooksInFolder()
'''''''''''''''''''''''''''''''
'Written by www.Ozgrid.com
'Open all found Workbooks in specified folder
''''''''''''''''''''''''''''''''
Dim i As Integer
With Application.FileSearch
.LookIn = "C:Data"
'* represents wildcard characters
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then 'Workbook exists
For i = 1 To .FoundFiles.Count
Workbooks.Open (.FoundFiles(i))
Next i........
View 9 Replies
View Related
Oct 24, 2013
i get the following error everytime i open my workbook
Removed Records: Object from /xl/printerSettings/printerSettings2.bin part (Print options)
Removed Records: Object from /xl/printerSettings/printerSettings3.bin part (Print options)
ive tried everything. ive attached the workbook (obviously with all data removed).
View 5 Replies
View Related
Mar 26, 2009
I thought that I had this working completely, but the test to see if the "file is already open" isn't working.
Something is wrong with my example.
I have marked in the code where the problem is. Everything else works. It's marked as such: ...
View 4 Replies
View Related
Aug 29, 2012
I am using below code to open file from 2 diff. folder and trying to do vlookup.
Its working in single loop but not moving to next file
Error: Invalid procedure or call argument.
Sub vFunction()
Dim strTempName As String
Dim strPath As String
Dim wb As Workbook
Dim wb1 As Workbook
Dim strFile As String
Dim strFile1 As String
[Code] ...........
View 2 Replies
View Related
Nov 25, 2013
I'm trying to add a little error handling in my code. I have a macro that, when running opens a number of workbooks. At the end of the macro, my code then closes all the workbooks I've opened.
I was wanting to create an error-handling procedure that displayed a message box, and then closed any workbooks that I've opened during the course of the macro. Obviously the error could trigger at any point, so not all workbooks may have been opened at the time
My code is as follows - I've tried On Error Resume Next in the error-handling code, but Excel still returns an error that it can't find the Incidents_MTD sheet when trying to close it.
Code:
On Error GoTo ReportError
code
code
code
ReportError:
[Code].....
View 4 Replies
View Related
Oct 20, 2013
I'm using 2003 (I know!) version & I can't open excel files directly by clicking on them. I get an "error in sending command" message. I can circumvent problem by opening Excel & then opening the relevant file, but this sometimes causes me problems.
View 4 Replies
View Related
May 20, 2012
The code opens the book but the activation line gets a subscript out of range error.
Code:
Workbooks.Open File
Workbooks(File).Worksheet("Disc_Nodes").Activate
View 1 Replies
View Related
Sep 17, 2008
I am opening the file through the GetOpenFilename method. I am facing an error in of the cases... Like say or example i try and open a file with the XYZ.xls...which is already open. the system generates a mess saying
"reopening will cause any changes you made to be discarded. do you want to reopen XYZ.xls?"
if i click yes...it works fine by reopening the file but when i click to No...Runtime error 1004 comes:
"Method open of object workbooks failed "
and its giving an error here in the Workbooks.Open Filename:=sFilename ......
View 9 Replies
View Related
Jul 7, 2006
I am trying to display the Filename in a cell on my worksheet. However, when I enter the =Cell("filename"), it provides the full path (C:/Documents......Cost Summary.xls) How can I display only the filename without the path?
View 3 Replies
View Related
Oct 27, 2011
I am using this code to open a form in Excel:
Code:
Private Sub Workbook_Open()
Form1.Show
End Sub
It has worked perfectly for about 2 weeks, well now when I go to open the workbook it gives me the debug error of Run Time error 424 Object Required. I last ran this today at about 8 a.m. no errors, but now about 4 hours later, it is bugging out. What is causing this?
View 3 Replies
View Related
Sep 7, 2007
I have a macro that checks if a username is in a particular list, and if it is, it unhides certain sheets in the workbook.
The code runs fine if I just run it as a macro or off a command button, but I am trying to execute it when the workbook opens and I keep getting a 57121, Application defined or object defined error.
The code is below;
Private Sub Workbook_Open()
DoEvents
Dim Res1 As VbMsgBoxResult
Dim GovRng As Range
For Each GovRng In Sheets("Map").Range("GovernanceMembers")
If GovRng.Value = Application.UserName Then Goto 111
Next GovRng
Exit Sub
View 6 Replies
View Related
Oct 3, 2007
I have a program that uses the Document Open event to display a custom form. This program is being used on about 50 computers for the past 8 years with no problems. One user has a problem now. They can open the program once and the code fires. But when the user tries to open the same file a second time, the "Microsoft Excel has encountered a problem and needs to close" dialog box is displayed. The document that is recovered has no vba modules and no code in the Document open event. I've uninstalled and reinstalled Office Professional. Shut down all firewalls.
View 9 Replies
View Related
Nov 14, 2012
I am trying to adapt a macro to run on data that is consistently in the same format but the data does change, the macro needs to run over and over on new excel workbooks, dynamic range ? instead of a set source ?
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"weekly71012!R1C1:R9379C30", Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:="PivotTable1" _
, DefaultVersion:=xlPivotTableVersion14
I am sure this is the problem as i initially created the macro using weekly71012 excel file however i just want it to run on every file i pull it off?
View 2 Replies
View Related