The problem with QBFC is that it doesn't give you an option to check if it's open or if the company file is the same you are trying to open.
If you are okay with just forcing the current QB company file to close, then the following code should do the job.
On Error Resume Next
Dim smgr As QBSessionManager
Dim oServ As Object
Dim cProc As Variant
Dim oProc As Object
Set oServ = GetObject("winmgmts:")
Set cProc = oServ.ExecQuery("Select * from Win32_Process")
Set smgr = New QBSessionManager
smgr.OpenConnection "", "Job Management"
smgr.BeginSession "", omDontCare
If Err.Number <> 0 Then
'Kill the current running Quickbooks process
For Each oProc In cProc
If oProc.Name = "QBW32.EXE" Then
oProc.Terminate
End If
Next
'Close the connection and try again
smgr.CloseConnection
smgr.OpenConnection "", "Job Management"
smgr.BeginSession "", omDontCare
End If