Skip to content

Hints & Tips

Paul Woolcock edited this page Nov 4, 2023 · 14 revisions

Syncing Multiple Calendars

From v2.9.3, OGCS introduced Profiles that allow multiple calendar syncs to be configured within one running instance of OGCS. If you need to sync calendars from more than one Google account, however, read how to run multiple instances of OGCS.

From v2.7.6, OGCS also supports two-way sync between a "common" calendar. For example, Outlook Workplace 1 ↔️ Google calendar ↔️ Outlook Workplace 2.

⚠️ If you are on an earlier version than v2.7.6, do not sync more than one source calendar into the same destination calendar. In these early versions, only the following configurations are supported:

image

From v2.7.2, OGCS can be run with additional parameters to specify different settings and logfiles for each instance.

Restoring OGCS Configuration

If you are setting OGCS up on a new computer, or would like to restore your old settings for some reason, it's as simple as taking the backed up version of your settings.xml file and replacing the newly created one. See the instructions for deleting the configuration in order to locate the file you need to replace.

Fixing a Stubborn Unwanted Deletion with Full Sync

Sometimes during a two-way sync, a calendar item might always get flagged for deletion when it shouldn't.

ℹ️ Aug-2023: As of v2.10.2, when declining the deletion of such an item, it will re-sync it instead.

On earlier versions, or for a more manual resolution, it may be possible to resolve this by forcing a full one-way synchronisation.

The following example is for an unwanted Outlook deletion:

  1. If you have two-way sync configuration, once you're sure Google has no further changes that need syncing to Outlook, set OGCS to one-way sync: Outlook to Google.
  2. Force a full sync by pressing and holding the Shift key while clicking the Sync button
  3. The item flagged for deletion should sync to Google
  4. Set OGCS back to two-way sync, if necessary
  5. Perform a normal (differential) sync by just clicking Sync and confirm the undesired deletion prompt no longer occurs

Removing All OGCS Metadata From Your Calendars

⚠️ This is a much more drastic measure than the above. It may, however, help resolve odd/unexplained sync behaviour - but this is an advanced process and likely should not be attempted unless suggested by the project owner in an Issue.

To facilitate the synchronisation, OGCS will hold extra pieces of information (metadata) against calendar entries. These can be removed by carrying out the following steps, which will revert your calendar(s) to a state resembling that before OGCS ever performed its first sync.

  1. Go to the About tab and double click the Config In file location to open Windows Explorer, then close OGCS
  2. From Windows Explorer, open settings.xml in a text editor and find the ExtirpateOgcsMetadata entry.
  3. Change its value from false to true, save the file and close it
  4. Start OGCS - you'll have a warning and a red sync button
  5. Click Sync and purge your calendars of metadata.
  6. Close OGCS and change the setting back to false
  7. Start OGCS and run a sync - all your items will get "reclaimed" on the first sync before subsequent syncs continue as normal

Mass Deleting Synced Items

Sometimes it may be desirable to remove all the items that have been synced to a calendar, for example due to a misconfiguration or wanting to back out some testing. This is not built into OGCS, primarily because it is a dangerous operation that I don't want to make easily available.

However, I have provided a guide on a semi-automated mechanism - it is reasonably technical, but probably tempting if you don't want to have to manually delete hundreds of items!

Delayed Startup of OGCS

⚡ This feature is now built in to OGCS from v2.5.3, but for reference there is also the below manual workaround too.

If starting OGCS on startup of Windows causes problems with Outlooks own startup sequence, the following VBA script calls OGCS after Outlook has done its own startup things.

Start OGCS After Outlook

Copy and paste the code into Outlook's ThisOutlookSession VBA module (hit Alt+F11 to open the editor).

📍 Make sure the variables in the Configure() Sub point to your installation of OGCS.

Dim eventClass As New EventClassModule
Public ogcsDirectory, ogcsExecutable, ogcsProcessName As String
Public ogcsStartWithOutlook As Boolean

'Load the right driver bitness at runtime
#If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long _
    ) As Long
#Else
    'Don't worry if compiler highlights in red - it isn't instantiated at runtime for 64-bit systems
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long _
    ) As Long
#End If

Private Sub Configure()
    'Set these variables as appropriate for your installation of OGCS
    ThisOutlookSession.ogcsDirectory = Environ("LOCALAPPDATA") & "\OutlookGoogleCalendarSync"
    ThisOutlookSession.ogcsExecutable = "OutlookGoogleCalendarSync.exe"
    ThisOutlookSession.ogcsProcessName = Replace(ThisOutlookSession.ogcsExecutable, ".exe", "", 1, 1, vbTextCompare)
    ThisOutlookSession.ogcsStartWithOutlook = True
    
    'Log settings
    Debug.Print ("ogcsDirectory = " & ThisOutlookSession.ogcsDirectory)
    Debug.Print ("ogcsExecutable = " & ThisOutlookSession.ogcsExecutable)
    Debug.Print ("ogcsProcessName = " & ThisOutlookSession.ogcsProcessName)
    Debug.Print ("ogcsStartWithOutlook = " & ThisOutlookSession.ogcsStartWithOutlook)
    
    If (Len(Dir(ThisOutlookSession.ogcsDirectory & "\" & ThisOutlookSession.ogcsExecutable)) = 0) Then
        MsgBox "The specified location of OGCS is not valid." & Chr(13) & "Please update the VBA configuration section.", vbCritical, "Invalid OGCS VBA Configuration"
    End If
End Sub

Private Sub Application_Startup()
    Configure
    
    If (ThisOutlookSession.ogcsStartWithOutlook) Then
        'Start OGCS
        Dim RetVal As Long
        On Error Resume Next
        
        'https://docs.microsoft.com/en-us/windows/win32/shell/shell-shellexecute#parameters
        Const ogcsWindowSize_Normal = 1
        Const ogcsWindowSize_Minimised = 2
        Const ogcsWindowSize_Maximised = 3
        Const ogcsWindowSize_RecentSizeAndPosition = 4
        Const ogcsWindowSize_CurrentSizeAndPosition = 5
        Const ogcsWindowSize_MinimisedActiveWindowRemains = 7
        Const ogcsWindowSize_DefaultState = 10
        
        RetVal = ShellExecute(0, "open", ThisOutlookSession.ogcsDirectory & "\" & ThisOutlookSession.ogcsProcessName, _
            ogcsWindowSize_Normal, ThisOutlookSession.ogcsDirectory, 3)
    End If

    Private Sub Application_Quit()
        Dim oServ As Object
        Dim cProc As Variant
        Dim oProc As Object

        Set oServ = GetObject("winmgmts:")
        Set cProc = oServ.ExecQuery("Select * from Win32_Process")

        For Each oProc In cProc
            If oProc.Name = "OutlookGoogleCalendarSync.exe" Then
              oProc.Terminate (0)
            End If
        Next
    End Sub
End Sub