Saving a file by using a macro

mikeywhits

Board Regular
Joined
Jun 7, 2010
Messages
80
Hi all,

Does anyone know how to use a macro to save a file? if this is possible?????

What i am trying to do is open a file dated 19/6 and then run a macro which would save it to a folder as 20/6 - but this would need to add 1 day each time.

Regards,

Mike
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi Mike, Here see the code... . AS excel can not be save '\' with this. so if your file name is like 19-6 then it will work . or let me kno excatly name of your file.




Code:
Sub saveAsdisplay()
Dim fPth As Object
Set fPth = Application.FileDialog(msoFileDialogFilePicker)
        
        With fPth
            .InitialFileName = ThisWorkbook.Path & "\"
            .Title = "Select Data File :"
            .InitialView = msoFileDialogViewList
            If .Show = True Then
                filePth = Application.FileDialog(msoFileDialogFilePicker).SelectedItems(1)
            Else
                Exit Sub
            End If
        
        End With
              
        filenm = CreateObject("Scripting.FileSystemObject").GetBasename(filePth)
       
        Set wbkOpenFile = Workbooks.Open(filenm)
       filestr = Format(CDate(filenm) + 1, "dd-mm")

        Set fPth = Application.FileDialog(msoFileDialogSaveAs)
        
        
        
        With fPth
            .InitialFileName = filestr
            .Title = "Save your File:"
            .InitialView = msoFileDialogViewList
             If .Show = True Then
                 .Execute
              Else
              Exit Sub
             End If
            
        End With
        wbkOpenFile.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,207,096
Messages
6,076,555
Members
446,213
Latest member
bettigb

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