Microsoft Office

Google Calendar Sync – Auto Run

A nice quick hint.

I kept forgetting to start Google Calendar Sync when I started Outlook. I don’t always start Outlook when I start my laptop and I’m not always online when I run Outlook so puting it in my Startup folder is not really an option.
My solution, a macro that runs when Outlook starts that gives me the option of running Google Calendar Sync if I feel it’s appropriate.

Private Sub Application_Startup()
Dim response As Integer
Dim RetVal
response = MsgBox(prompt:=”Do you want to run Google Calendar Sync?”, buttons:=vbYesNo)

If response = vbYes Then
RetVal = Shell(“C:\Program Files\Google\Google Calendar Sync\GoogleCalendarSync.exe”, vbMinimizedNoFocus)
End If

End Sub

NOTE: WordPress seems to “prettyfy” the quotes so when copying the code above it is better to delete and retype the quotation marks in your code editor of choice.

11 replies on “Google Calendar Sync – Auto Run”

Ross, I tried to use this macro with Outlook 2007 and I got syntax errors on line 4. I tried removing the colons, which may have helped, but I also got errors on line 6.

I have almost no experience with VBA; do you know why I got these errors?

Thanks, -Mike.

I am no VBA programmer either, I just “dabble”.
I have double checked this code in Outlook 2007 and 2010 and it works with no modifications.

Maybe if you could show me the code you are running and the error message I can help.


Thanks for the quick reply.

I get get “Compile error: Syntax error” with the 4th line (response =…) highlighted (highlit? )

I sent you a screen grab; it may reveal something else…

Thanks again,


That did it! Thanks!

When I have time, I may try to get Outlook to run Google Calendar Sync automatically (without the MsgBox) and then close Sync before it exits…

…So you may not have heard the last of me.

Thanks again,


Apologies, my reply was via e-mail rather than comment on here.
The problem was in the double quotes.
These should be plain and simple double quotes and not fancy opening and closing double quotes.

Ross, I’m getting the same error as Mike when trying to use the macro with Outlook 2007. Could you please let us know what solution you provided for him? Thanks!

Sorry, I missed your post above during my first read thru. Problem solved, script works perfectly. Its really useful, thanks again.

Hi. I have no VB idea. The furthest I have reached is to build a macro with the Ross command, but the macro only works if I delete the word “Private”, and of course, the macro is not working at the beginning of Outlook.
Many Thanks

I got lots of compile errors as posted.
This code worked for me:

Private Sub Application_Startup()

Dim r As Variant
Dim RetVal As Variant
Dim filename As Variant

vbFileSeperator = “\”

filename = “C:” & vbFileSeperator & “Program Files” & vbFileSeperator & “Google” & vbFileSeperator & “Google Calendar Sync” & vbFileSeperator & “GoogleCalendarSync.exe”

r = MsgBox(prompt:=”Start Google Calendar Sync?”, buttons:=vbYesNo)

If r = vbYes Then
RetVal = Shell(PathName:=filename, windowstyle:=vbMinimizedNoFocus)
End If

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *