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.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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
 
Upvote 0
Cheers matey!

This works an absolute treat!

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

J
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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
Back
Top