VBA Open Filename Works For Some Users Fails For Others

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


ADVERTISEMENT

Formatting Text Fails In 97 But Works In 2003

Mar 21, 2007

This script works great in 2003 in formatting text brought from Access, but fails in 97 - unfortunately I don't have direct access to Excel 97 - can anyone with it (or with a compendious knowledge of the differences!)

View 9 Replies View Related

Array Match Formula Fails But Simple Match Works?

Feb 5, 2014

In sheet 1, I have

Col A Col B
John Sedgwy - R

In sheet 2, I have the following names

Col A Col B
Peter Walker
John Sedgwicky

When I did an array match -> ={MATCH(1,(TRIM($a2)=Sheet2!$A$1:$A$2)*(left(b2,5)&"*"=Sheet2!$b$1:$b$2),0)}

gave me an error but when I did an individual match to both John and Sedgw, it works.

View 4 Replies View Related

Fails To Open A File

May 3, 2007

I downloaded a file from Excel-Logic site called :finding_dupes.xls.I can open this file in Office XP & Office 2007,but cannot open it in Office 2003.It just opens it and then hangs.I am attaching this file.

View 7 Replies View Related

Workbook Open Code Fails

Oct 4, 2006

I tried testing, msgbox displays the correct last modified file "MMO Activity Report 09-29-06.xls" in path D:MMOWorkfile but I was not able to open the workbook.

Sub testGetNewestFile()
MsgBox NewestFile("D:MMOWorkfile", "*.xls")
Workbooks.Open (NewestFile("D:MMOWorkfile", "*.xls"))

View 9 Replies View Related

Open File With Date In Filename

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

Error-prooofing Get Open Filename

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

Hyperlinks With # In Filename Wont Open

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

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 View Related

Vba - Input Filename To Open Each Time

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

Open File With Changing Filename-2007

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

Open File In Directory With Part Of Filename As String

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

Open A File, Extract & Paste The Filename Into Another Workbook

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

Open File With Inputbox Result In The Middle Of The Filename Address

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

Excel 2010 :: Macro To Open XLSM File Based On Latest Date Found In Filename

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

2002 Code V 97 Code: Add A Small Workbook Open Event Code Which Works For Me But Debugs For The Others

Jan 27, 2009

I use excel 2002 but some of my office are on 97, i want to add a small workbook open event code which works for me but debugs for the others?? The code is basically, go to a tab, on that tab and that range sort..

View 2 Replies View Related

Amending The Filename In Cell("filename")

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

VBA Fails To Paste The Value

Jan 22, 2010

I've attached a model with my problem highlighted in COLUMN S of the REPORT tab. The model is an example of what the output should be, but if you run "Full Report" (Command Click 1) you'll see that when the VBA code gets to the penetration operation, it fails to paste the value. The identical code works perfectly in the "Subs Report" (Command Click 2). This is the code in question as part of a for loop:

View 2 Replies View Related

No To Overwrite Fails Macro

Jun 18, 2009

if i run my macro that saves a sheet as a certain name and then prints it, it works, but if i run my macro and the file already exists it asks me to overwrite it. If i select yes it prints it and carrys on with the rest of the macro, (good). If i select no the macro fails. How can i get it so if i hit no, it runs the rest of the macro after the print command?

View 2 Replies View Related

CommandButton And FIND Fails

Sep 16, 2009

Haven't done a LOT with forms, but this should work (in my mind) and doesn't.

I'm using a ComboBox linked to a named range of "DATES" for a user to select a date. All I want to do is find that date in column A of the Sheet1.

View 7 Replies View Related

Insert Picture Sub Fails In '07

Dec 31, 2009

The code below will enable you to browse for a picture and insert it at cell location O9. It works great in excel '03 but when sub is ran in '07 it places the picture at about cell D5 and not really even lined up perfectly with that cell. Does any one have any idea why this is happening and how to make the sub work correctly in '07?

View 6 Replies View Related

Numbers Only In Textbox Fails

Apr 6, 2012

I have a TextBox on a multipage on a userform. When used, entries are trapped by

Private Sub tbxCrew_Change()
Call OnlyNumbers

The code then successfully shifts to the following

Private Sub OnlyNumbers()
If TypeName(Me.ActiveControl) = "TextBox" Then

At this point, it decides that TypeName(Me.ActiveControl) = "MultiPage", not "TextBox" and skips over to End Sub allowing me to enter both text and numbers in the TextBox.

View 4 Replies View Related

Select Case Gets To End And Fails

May 29, 2013

I am having issues with a Select Case failing at the end. Here is the code:

Code:
Public jan As Double
Public feb As Double
Public mar As Double
Public apr As Double
Public may As Double
Public jun As Double

[Code] ........

I have bolded the font on where it fails. If I delete the bolded lines the code runs perfect.

View 3 Replies View Related

Identify Line That Fails?

Oct 14, 2013

I've got a Userform with hundreds of lines of code and I'm getting Run Time Error 424, Object Required when I try to show it - the problem is that it doesn't take me to the line that fails - is there a way I can identify the problem?

View 5 Replies View Related

FileSearch Fails In 2007

Aug 22, 2008

Before upgrade to Microsoft 2007 this code worked well (for 3 years). I marked it well with big space & comment where it gets hung up. The line says: With Application.Filesearch. All is well up to that point. I have another program that seems to have a problem when it comes to "With Application" as well. It must have to do with the upgrade, because my programs have been used daily, and it was right after the upgrade that it got buggy. All of the users were upgraded to Microsoft 2007 at the same time.

Sub Rpitracking()
'Collects data from records
Application.ScreenUpdating = False

Dim MyCandidate
Sheets("PI Tracking").Activate
Set Level = Range("I5:I100")
Sheets("PI Tracking").Range("J5:Z100").Select
Selection.ClearContents 'Clears info pulled from records
Sheets("PI Tracking").Range("5:100").Font.ColorIndex = 0 'Colors all rows black
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
Range("ID").Offset(1, 0).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
'Application.Calculation = xlAutomatic
For Each Cell In Level
Cell.Select
If Cell.Value <> "" Then 'Checks to see if Application date us there
If Cells(Cell.Row, 9).Formula <> "" Then 'Checks to see if app date is there
MyCandidate = Cells(Cell.Row, 2) & " " & Cells(Cell.Row, 1)

View 4 Replies View Related

Loop Fails To Remove Value

Apr 18, 2007

I am trying to remove values in column D if the value in anyone of the rows in column D is zero, here is the macro, for some reason it only removes some of the zeros, if I run it multiple times it eventuelly removes all the zeros:

Sub Removezeros()
Dim rct As Long
Dim i As Long
rct = Application.WorksheetFunction. CountA( Range("d2", Range("d65536").End(xlUp)))
For i = 2 To rct
If Cells(i, 4).Value = 0 Then
Cells(i, 4).EntireRow.Delete
Else
End If
Next i
End Sub

View 4 Replies View Related

Macros Fails In UserForm

Feb 11, 2008

I have a number of Macro's that work in excel, but when I assign them to a userform I've created they hang... They activate, but where the macro requires a cut/copy, filter etc of data in the worksheet the code Breaks and I have to debug. Very frustrating because they work fine in excel. Its just the introduction of the user form which is giving me trouble. Is there a way of turing off the userform, getting the macro to run, and then reopening the userform... I've tride Userform.hide... but it doesn't seem to work.

View 5 Replies View Related

Macro Fails When Data Is Filtered?

Mar 14, 2014

I have a macro that sends a sheet via email when the engineer has completed it and clicks a button. I added a filter to some of the results to remove blank lines and now the macro will not work. The problem is that if I remove the filter so that the macro does work, I end up with blank lines again.

View 4 Replies View Related

If Macro Fails :: Let The Sub Carry On To Next Instruction

Nov 23, 2006

How can I let the Sub carry on to next instruction if Macro1 fails?

Private Sub Workbook_Open()

Call Macro1
' If Macro1 Fails go to next macro
Call Macro2
'If Macro2 Fails go to next macro
Call Macro3
'If Macro2 Fails go to next macro
Call Macro4

End Sub

View 9 Replies View Related

Copying Multiple Sheets Fails

Jan 8, 2007

I have a large workbook which has about 15 sheets. About half of these are template sheets which are copied multiple times within this workbook. The workbook is very large and can't be posted. I would like to hear from anyone who can give me any direction to look in given the following symptoms. The problem is that VBA code stops executing and gives a 1004 Error. *The problem is stable and reproduceable.

*It occurs exactly the same across three different computers with varying versions of Excel and memory.

*The problem is persistant beyond VBA. By that I mean if I stop the debugger and try to manually copy the active sheet, the screen flashes but the sheet is not copied. Therefore I think the 1004 error is a symptom rather than a cause

*From scratch, I get to copy 43 times before I get the error.

*If I then save the workbook and re-open (don't need to close Excel) I then get to copy another 27 sheets.................................

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved