search and save

Jorn

Board Regular
Joined
Jul 10, 2003
Messages
92
Good Afternoon,

I have a program which is nested into excel that is updated everycouple of days.

The problem is that people save the spreadsheet in a number of locations on their C:Drives, and these copies are not updated.

Would anyone have any idea as to what code you may use to search for the same filename on the C drive and save the current update to it? I would have this happen when the updated program is opened...

Any help would do!

Regards

John.
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

P Sitaram

Well-known Member
Joined
Jun 24, 2003
Messages
1,974
Put this in the Workbook_Open Event code:

Code:
Sub UpdateFiles()
    Application.ScreenUpdating = False
    
    Dim sFName, sFPath, sFullName As String
    Dim iCtr As Integer
    
    sFName = ActiveWorkbook.Name
    sFPath = ActiveWorkbook.Path
    sFullName = sFPath & "\" & sFName
    
    With Application.FileSearch
    .NewSearch
    .LookIn = "c:\" 'change to suit
    .SearchSubFolders = True
    .Filename = sFName
    If .Execute > 0 Then
      For iCtr = 1 To .FoundFiles.Count
        If .FoundFiles(iCtr) <> sFullName Then
            On Error Resume Next
            ActiveWorkbook.SaveAs .FoundFiles(iCtr)
            On Error GoTo 0
        End If
      Next iCtr
    End If
  End With
  
  Application.ScreenUpdating = True
End Sub
 

Jorn

Board Regular
Joined
Jul 10, 2003
Messages
92
Cheers matey!

This works an absolute treat!

One thing though- can i get it to save without prompting??

J
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hi,
I don't see psitaram on at the moment, so I'll give it a go.
I beleive if you put
Application.DisplayAlerts = False
right above this line
ActiveWorkbook.SaveAs .FoundFiles(iCtr)
and Application.DisplayAlerts = True right below it, you should be able to save these files without the prompt.
(Did I guess right on what you're wanting? :biggrin: )
Dan
 

Watch MrExcel Video

Forum statistics

Threads
1,123,524
Messages
5,602,169
Members
414,509
Latest member
Cdavis7078

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top