Auto Save after X mins with version number and then email....

dgrimm

Board Regular
Joined
Sep 17, 2007
Messages
159
Everyone and Anyone -

I have been asked if this is even possible, with Excel being pretty powerful with VBA I figured I would pose this question here.
I need a macro upon opening that will:
1. Auto save after x mins
2. Upon saving save with a different version number
3. Have this last for y hours
4. Email after each save

I have found code for version number but not for Auto Saving and then email on top of it.

Thank you

Dave
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
.

2. Upon saving save with a different version number

Code:
Option Explicit
Sub PlsOne()
Dim num As Integer
    Range("A1").Select
    num = Range("A1").Value
    num = num + 1
    Range("A1").Value = num
End Sub

1. Auto save after x mins

Call from ThisWorkbook_Open if desired or use a command button ?

Code:
Option Explicit


Const idleTime = 300 'seconds
Dim Start
Sub StartTimer()
    Start = Timer
    Application.DisplayAlerts = False
    Do While Timer < Start + idleTime
        DoEvents
    Loop
   ThisWorkbook.Save
   Application.DisplayAlerts = True
End Sub


4. Email after each save

Code:
Option Explicit


Sub Mail_workbook_Outlook()


    Dim OutApp As Object
    Dim OutMail As Object


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    On Error Resume Next
    With OutMail
        .to = "myaddr@yahoo.com"
        .CC = ""
        .BCC = ""
        .Subject = "Test"
        .Body = ""
        .Attachments.Add (Application.ActiveWorkbook.FullName)
        
        '.Send
        .display
    End With
    On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub


Understand these samples need to be edited/adjusted to fit into your project.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

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