UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Make A Version That Will Run On 2013, Access 2016    
 
   
Louverril
post Jun 14 2017, 05:53 AM
Post#1



Posts: 456
Joined: 29-April 08



Hello,

I use Access 2016 and until recently had a machine running Access 2013 (I "upgraded" to Office 365 Business Premium only to find out - asked directly at the time and told it would be ok but hey ho shrug.gif - that office 2013 was no longer available). However I need to send a database to someone using 2013 and these two 2016 references will not automatically compile on the 2013 machine.

Microsoft Outlook 16 Object Library (MSOUTL.OLB)
Microsoft Office (MSO.DLL)

See attached.

I cannot late bind the Outllook code I use (I use a class). But in any case the other reference also causes problems - although every now and again Access will manage to find it as the application opens (but only 1 in 10 times).

I did experiment by adding the two 2013 version of the above to the references - removing the 2016 ones. The database compile ok. However as soon as the database was reopened they returned to the 2016 versions.

Am I stuck - other than trying to get a version 0f 2013 (at more expense - ?

Thanks in advance for any thoughts.
Attached File(s)
Attached File  refs_on_16.JPG ( 48.19K )Number of downloads: 0
 

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
LPurvis
post Jun 14 2017, 06:13 AM
Post#2


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


Hi

You're, presumably, distributing an ACCDB file (as you say that the lower version references are occasionally found - this would usually be the case in an ACCDB, but can't happen in an ACCDE, where you have to distribute with the lowest common reference set.)
Why it's not regularly finding the lower references isn't really something that can readily be determined. But is there any possibility of adding them subsequently?
You could consider adding them through code (since this is an ACCDB that should be doable, though missing references will cause issues at startup, the references not being there at all would prevent the modules that use them to raise compile errors).
Or manually adding them on the target PC. (Or someone you have access to who can add them?)

If this is an ACCDE, then those users who got by must have those references on their PC for whatever reason. And you can't add a thing and must find an installation with 2013 so you can add them before distribution.

Cheers

--------------------
Go to the top of the page
 
LPurvis
post Jun 14 2017, 06:16 AM
Post#3


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


Out off interest, what are you using from the Office library that is required?
And what is in the class that you need early binding (is it perhaps something like my Outlook class which waits for an open email to be sent before recording such - sinking events from Outlook)?

Just wondering if there's any chance of avoiding the references.

Cheers

--------------------
Go to the top of the page
 
Louverril
post Jun 14 2017, 06:48 AM
Post#4



Posts: 456
Joined: 29-April 08



Hello Leigh,

Yes it's an accdb. And they want it to stay like that and they don't have plans to upgrade to 2016 in the short term :-(

I exchange versions with them frequently and also I can't MANUALLY add the references onto the target PC.

Ref "Just wondering if there's any chance of avoiding the references." - that sounds good.

Ref the Outlook reference: yes it is something like your Outlook email I think - this is the code below.

Ref the Office reference - there is a lot of code in there referencing the Ribbon - so I have to have this reference????????? e.g. Public gobjRibbon As IRibbonUI


CODE
'Manage Outlook
'You need a reference to the Outlook library to use this.

'http://stackoverflow.com/questions/21997876/handle-outlook-mailitem-send-event-in-access
'http://www.UtterAccess.com/forum/index.php?showtopic=2040128&st=0&gopid=2620139&#entry2620139

' If have problems getting email to front:
'       http://www.UtterAccess.com/forum/lofiversion/index.php/t2032190.html _
        https://msdn.microsoft.com/en-us/library/office/ff865654.aspx
'       http://www.UtterAccess.com/forum/lofiversion/index.php/t2021504.html


Public WithEvents OutApp As Outlook.Application
Public WithEvents OutMail As Outlook.MailItem



Private Sub Class_Initialize()

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

    If Not (OutApp.ActiveWindow Is Nothing) Then  'only if there's a window
            OutApp.ActiveWindow.Activate  'make sure outlook comes to foreground first
    End If
    
    OutMail.Application.ActiveWindow.Activate 'Try to ensure the email created is the active window
    If TypeName(OutApp.ActiveWindow) = "Inspector" Then 'Resize it -better than maximized
        OutApp.ActiveWindow.WindowState = olNormalWindow 'olMinimized
    End If
  
    
End Sub

Private Sub OutMail_Send(Cancel As Boolean)
'NOTES
'Outlook likes to resolve the addresses one by one and have no; in them
    
    Dim myRecipient As Outlook.Recipient
    Dim strRecipient As String
    Dim I As Integer
    Dim myArray() As String

    
    If gstrTo <> "" Then
        myArray = Split(gstrTo, ";")
        
         For I = 0 To UBound(myArray) 'Split into the individual addresses.
            strRecipient = myArray(I)
            If InStr(1, OutMail.To, strRecipient) = 0 Then 'The addresses for the To box originally sent have been deleted.
                    'Add the address back in
                    Set myRecipient = OutMail.Recipients.Add(strRecipient)
                    'Resolving them (otherwiese there will be an error
                    myRecipient.Resolve
                   ' Debug.Print "re added!"
            End If
        Next
    End If
End Sub


and to use it:
CODE
Public Function generateEmailControlled(strTo As String, strSubject As String, Optional strMessage As String, Optional strCC As String, _
                            Optional strBCC As String, Optional blnDisplay As Boolean, Optional strAttachment As String, _
                            Optional blnHTML As Boolean, Optional blnRP_MoveHTMLAttachmenttoBody As Boolean) As Boolean
'-------------------------------------------------------------------------------------------
'
' FIRST ADDED BY:         AC
' DATE ADDED:               27/10/16
' DESCRIPTION OF FUNCTION:  Rewrite of generateEmail for new class - so can controlled Outlook.
'-------------------------------------------------------------------------------------------
' AMENDED BY:                AC
' DATE AMENDED:           27/10/16
' AMENDMENTS MADE:  Rewrite for new classs
'-------------------------------------------------------------------------------------------
' AMENDED BY:              AC
' DATE AMENDED:         22/11/16
' AMENDMENTS MADE:  FindWindow, SetForegroundWindow
'--------------------------------------------------------------------------------------------
' NOTES: This code needs a reference to have a reference to the Microsoft Outlook Object Library.

' If have problems getting email to front:
'       http://www.UtterAccess.com/forum/lofiversion/index.php/t2032190.html _
        https://msdn.microsoft.com/en-us/library/office/ff865654.aspx
'-------------------------------------------------------------------------------------------

    On Error GoTo ITAError

    Const olMaximized = 0
    Const olNormalWindow = 2
    Const olMinimized = 1
    Dim strAttachmentContent As String
    Dim lngHwnd As Long
    Dim objOutlook As Object
    
'****************************************************************************
''Generate email
'****************************************************************************
    Set OutApp = New clsOutlookManager

    On Error Resume Next
    
    'If for any reason OutApp.CreateItem(0) = nothing _
    - for instance if the opening of outlook was cancelled here _
    an error will occur. Ignore it and procede to the exit.
    
    If Err Then
        Err = 0
        GoTo ITAExit
    End If

    On Error GoTo ITAError
        
     With OutApp.OutMail
         .To = strTo
         gstrTo = strTo 'So that is can be compared to the addresses present when the email is actually sent
         .CC = strCC
         .BCC = strBCC
         .Subject = strSubject

        'Display if set to display (will allow signature to be got)
         If blnDisplay = True Then
             .Display
              lngHwnd = FindWindow(vbNullString, CStr(.GetInspector.Caption))
             SetForegroundWindow lngHwnd
         End If
        
         'HTMLBODY
         'If this is HTML in the body of the email
         If blnRP_MoveHTMLAttachmenttoBody = True Then
             blnHTML = True 'Regardless of what was passed.
             If Len(Trim(strAttachment)) > 0 Then
                 '''''blnHTML = True DO YOU NEED THIS
                 If extractHTMLforReport(strAttachment, strAttachmentContent) = True Then
                     strMessage = strAttachmentContent & "<br><br>" & strMessage
                 Else 'don't try and copy attachment
                 End If
             End If
         Else
              'Add any attachment _
             ' NB HTML attachments must be added post display (office 2010 anyway!)
              If Len(Trim(strAttachment)) > 0 Then
                  .Attachments.Add strAttachment
              End If
         End If
        
        'Decide if want to send HTML formatted
         If blnHTML = True Then
             .HTMLBody = strMessage & .HTMLBody '& HTMLBody will add signature if present
         Else
             .Body = strMessage
         End If
                      
          'send
         If blnDisplay = False Then
           .Send 'sends straight away.
         End If
    End With
        
    generateEmailControlled = True
      
ITAExit:
    Exit Function

ITAError:
'    If Err.Number = 429 Then 'has happened on Vista if the email is password protected
'        Set OutMail = Nothing
'        Resume ITAExit
'    End If
    ITATrapErrors Err.Number, Err.Description, "GenerateEmail"
    generateEmailControlled = False
    Resume ITAExit 'Note exit
  ' Resume Next
End Function

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jun 14 2017, 07:05 AM
Post#5



Posts: 456
Joined: 29-April 08



PS: :-)

These are all the uses of the office library:

Public gobjRibbon As IRibbonUI - and a load of other ribbon references
Dim fd As FileDialog
.Rows("1:1").VerticalAlignment = xlCenter 'Center the header row
.Cells.VerticalAlignment = xlVAlignTop

Ref the Excel xlCenter and xlVAlignTop: there is a load of other Excel code that late binds and doesn't need the Office library but these do for some reason???

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
LPurvis
post Jun 14 2017, 07:08 AM
Post#6


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


Yep, that Outlook code is sinking events and thus requires a reference.
So we're back to you using an ACCDB and so are in a position to add the references. (Having distributed without them present.)

Now, obviously, you'll need to ensure the first code which runs in your application is the reference adding code. (Checking/error handling appropriately.)
But in basic concept, it's like the attached example.
(You might want to use AddFromGUID instead of AddFromFile if you're not going to be able to determine the location of the required reference file.)

Cheers
Attached File(s)
Attached File  AddRef.zip ( 18.79K )Number of downloads: 6
 

--------------------
Go to the top of the page
 
Louverril
post Jun 16 2017, 05:50 AM
Post#7



Posts: 456
Joined: 29-April 08



Thanks very much for this Leigh!!!

I will take a look at this - been manic the last day or so, so might not respond for a few days depending how things go.

But thanks - being in control of teh references will be great.

Allyson

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
LPurvis
post Jun 16 2017, 06:58 AM
Post#8


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


No worries.
Enjoy the sunny weekend (it's looking OK int' south of Yorkshire.)

--------------------
Go to the top of the page
 
Louverril
post Jun 16 2017, 08:46 AM
Post#9



Posts: 456
Joined: 29-April 08



Thanks and you - I will try - Not too bad int'North either :-)

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jun 16 2017, 02:34 PM
Post#10



Posts: 456
Joined: 29-April 08



Hello Leigh,

I did some work on this. This is what I have so far below. I thought it would be useful to have code to add the correct versions of these two references.

I am trying to pick up the correct locations for the references based on the office version and whether the system is 32 or 64; delete any wrong references and add the right ones.

I have two main issues:
1. How to pick up the root - e.g. C:\ ????
2 How to check if the right references already exist - got an idea see the comments,

Plus The location of MSOUTL.OLB varies between version 15 and 16 (and I need to double check MSO.DLL) - so I am in the middle of finding the most common ones.

Any thoughts?


CODE
Dim strVersion As String 'Use to check the version of Access

Public Function addReferenceOL()

    Dim strRef As String
    
    On Error GoTo ITAError
    
'--------------------------------------------------------------------------------------------
' Get the Version of Access
'-------------------------------------------------------------------------------------------
    If Application.Version = 16 Then
        strVersion = "Office16"
    ElseIf Application.Version = 15 Then
        strVersion = "Office15"
    Else: msgGeneralError "The version of Access cannot be determined! " & vbCrLf & vbCrLf & "The system cannot be opened."
        Application.Quit
    End If
    
'--------------------------------------------------------------------------------------------
'  Check if the  right references exist
'-------------------------------------------------------------------------------------------
    'Check if any version of references is present
    
    '....CODE TO GO HERE
    ' USE something related to this  ???
'    for each item in References
'    If References.Item(intI).Name = "the name youare looking for" Then
'        blnFound = True
'    Next
    
    'If the wrong references are present remove them
     '....CODE TO GO HERE
    'Using something like this
    Access.References.Remove Access.References(strReferenceName)
    
'--------------------------------------------------------------------------------------------
'  Add the Right References
'-------------------------------------------------------------------------------------------
    strRef = strDetermineRef1
    
    If strRef <> "" Then
        Application.References.AddFromFile strRef
    Else
        msgGeneralError "The system version (32 or 64 bit) cannot be determined! " & vbCrLf & vbCrLf & "The system cannot be opened."
        Application.Quit
    End If
    
      
    strRef = strDetermineRef2
    
    If strRef <> "" Then
        Application.References.AddFromFile strRef
    Else
        msgGeneralError "The system version (32 or 64 bit) cannot be determined! " & vbCrLf & vbCrLf & "The system cannot be opened."
        Application.Quit
    End If
    
    
    onAutoexec
  
ITAExit:
     Exit Function

ITAError:

    ITATrapErrors Err.Number, Err.Description, "addReferenceOL"
    'MsgBox Err.Number & " " & Err.Description
    Resume Next
    'Resume ITAExit
End Function


Function strDetermineRef1() As String
'-------------------------------------------------------------------------------------------
' FIRST ADDED BY:           ITA - AC
' DATE ADDED:               17/10/2016
' DESCRIPTION OF FUNCTION:
'-------------------------------------------------------------------------------------------
' AMENDED BY:       ITA - AC
' DATE AMENDED:
' AMENDMENTS MADE:
'--------------------------------------------------------------------------------------------
' NOTES:
'-------------------------------------------------------------------------------------------
    
    If intBitSystem = 32 Then
    
        If FileExists("C:\Program Files\Microsoft Office\Root\" & strVersion & "\MSOUTL.OLB") = True Then
            strDetermineRef1 = "C:\Program Files\Microsoft Office\Root\" & strVersion & "\MSOUTL.OLB"
        Else: strDetermineRef1 = "C:\Program Files (x86)\Microsoft Office\Root\" & strVersion & "\MSOUTL.OLB"
        End If
    
    ElseIf intBitSystem = 64 Then
        strDetermineRef1 = "C:\Program Files\Microsoft Office\Root\" & strVersion & "\MSOUTL.OLB"
  
    End If
    
        ' or could be Program Files\Microsoft Office\Office15.
        ' or "C:\Program Files\Microsoft Office\Office15\MSOUTL.OLB"
        'or in laptop4 case case "C:\Program Files (x86)\Microsoft Office 15\Office15\MSOUTL.OLB"

    
End Function
Function strDetermineRef2() As String
'-------------------------------------------------------------------------------------------
' FIRST ADDED BY:           ITA - AC
' DATE ADDED:               17/10/2016
' DESCRIPTION OF FUNCTION:
'-------------------------------------------------------------------------------------------
' AMENDED BY:       ITA - AC
' DATE AMENDED:
' AMENDMENTS MADE:
'--------------------------------------------------------------------------------------------
' NOTES:
'-------------------------------------------------------------------------------------------

    If intBitSystem = 32 Then
    
        If FileExists("C:\Program Files\Common Files\microsoft shared\" & strVersion & "\MSO.DLL") = True Then
            strDetermineRef2 = "C:\Program Files\Common Files\microsoft shared\" & strVersion & "\MSO.DLL"
        Else: strDetermineRef2 = "C:\Program Files\Common Files\microsoft shared\" & strVersion & "\MSO.DLL"
        End If
    
    ElseIf intBitSystem = 64 Then
        strDetermineRef2 = "C:\Program Files\Common Files\microsoft shared\" & strVersion & "\MSO.DLL"
  
    End If
    
End Function

Function intBitSystem() As Integer
'https://msdn.microsoft.com/en-us/library/office/gg264614.aspx
'http://www.UtterAccess.com/wiki/index.php/Conditional_Compilation
'http://www.jkp-ads.com/articles/apideclarations.asp
'http://www.ozgrid.com/forum/showthread.php?t=196916

#If Win64 Then 'Access is the 64 bit version
'Use Win 64 specific code
    intBitSystem = 64
    
#ElseIf Win32 Then 'Access is the 32 bit version
  'Use Win 32 specific code
     intBitSystem = 32
#Else
'Use Win 16 specific code
    intBitSystem = 1 'Cannot find the version
#End If

End Function

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
LPurvis
post Jun 17 2017, 05:22 AM
Post#11


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


Hi

Well, I did mention perhaps using AddFromGuid instead. With all that effort you're having to go to, the least I can do is go to the effort of finding out Outlook's Reference GUID. (I didn't know it offhand unsurprisingly. ;-)
When you're needing to determine the GUID, just check the reference number and you can use
?references(5).Guid
(Where Outlook was the 5th reference in this case.)

This should do you. (As in the entirety of the code you need.)
Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 0, 0

Cheers

--------------------
Go to the top of the page
 
Louverril
post Jun 19 2017, 10:06 AM
Post#12



Posts: 456
Joined: 29-April 08



Hello Leigh,

Many thanks!!!

Well that simplified things a bit! :-). Here's what I have now - any thoughts. All I need is an Access 2013 license to try it on Access 2013 - doesn't come with Business Premium. When I have done that I will let you know.

CODE
Public Function addReferenceOL()
'--------------------------------------------------------------------------------------------
' NOTES: ? references(intRefNo).Guid
'-------------------------------------------------------------------------------------------

    Dim strRef As String
    Dim refItem As Reference
    Dim intRefNo As Integer
    
    On Error GoTo ITAError
    
'--------------------------------------------------------------------------------------------
'  Remove any broken references
'  Add the Right References
'  The 0,0 should pick the latest version installed on that machine
'-------------------------------------------------------------------------------------------
    intRefNo = 1
    For Each refItem In References
        Debug.Print refItem.Name & intRefNo
        Debug.Print "Version: " & refItem.Major & "." & refItem.Minor
        If refItem.IsBroken Then
                Application.References.Remove refItem
                If refItem.Name = "Outlook" Then
                    Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 0, 0 'Outlook ref.
                ElseIf refItem.Name = "Office" Then
                    Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 0, 0 'Office ref
                End If
        End If
'--------------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------------
        intRefNo = intRefNo + 1
    Next
  
ITAExit:
     Exit Function

ITAError:

    ITATrapErrors Err.Number, Err.Description, "addReferenceOL"
    'MsgBox Err.Number & " " & Err.Description
    Resume Next
    'Resume ITAExit
End Function

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
LPurvis
post Jun 19 2017, 10:43 AM
Post#13


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


Cool, fingers crossed. (Sorry, don't happen to have 2013 to test it for you either... just either side of it. :-p)

Cheers

--------------------
Go to the top of the page
 
Louverril
post Jun 20 2017, 11:47 AM
Post#14



Posts: 456
Joined: 29-April 08



I just can't get this to work. iconfused.gif


I can add the references below to the Access 2013 Runtime application (on that different PC) - if the references for Office 16 were removed manually before I installed it.

But I cannot remove the broken Outlook 16 reference AND THEN add a 15 (2013) reference.

Once I specified the exact Major and Minor version for the Office DLL that works on the 2013 PC but I cannot get the Outlook to be removed when its broken and then added back in.

So justaddReferences works (as long as I remember to manually remove the Office 16 and Outlook references first) but not addReferences - with the remove code.

With addReferences when I try to re-add the references I get Error 32813 "Name Conflicts with Existing ...." as if the references when found to be broken were not removed. If I try to reference the name I cannot - presumably because you can't when the reference is broken - but in that case why wasn't if removed?

See the attached and the code below

CODE
Public Function addReferences()
'--------------------------------------------------------------------------------------------
' NOTES:   Remember you can't reference the name if the reference is broken.
'          The 0,0 should pick the latest version installed on that machine - _
           this doesn't work for office on our PCs with multiple versions of Access (because of the runtime versions)

' TIP      If you want to add other references and you have Excel on the target machine but only Access runtime, _
           you can find teh GUIDs through EXCEL

' LIMITATIONS: Does not cover the 64 GUIDS _
               Makes an assumption about the missing references _
               Use must deliver the system will the references present - in order to check if they are broken _
               and force a re-add of the correct version. _
               Only works with Office 15.0 (2013) and 16.0 (2016)
'-------------------------------------------------------------------------------------------
    Dim refItem As Reference
    Dim intRefNo As Integer
    Dim blnBroken As Boolean
  
    On Error Resume Next 'GoTo ITAError

    intRefNo = 1
    
    MsgBox "b4 scan refs"
    For Each refItem In References
         If refItem.IsBroken Then
            'MsgBox "Broken"
            blnBroken = True
            Application.References.Remove refItem
         End If
         intRefNo = intRefNo + 1
    Next
            
'--------------------------------------------------------------------------------------------
' If there have been broken references assume these are for Office and Outlook. _
  Add the references for Outlook and Office
'-------------------------------------------------------------------------------------------
    'MsgBox "after scan refs"
    If blnBroken = True Then
        If SysCmd(acSysCmdAccessVer) = "16.0" Then
            Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 2, 8 'Office 16 ref
            Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 0, 0 'Outlook ref.
        ElseIf SysCmd(acSysCmdAccessVer) = "15.0" Then
           MsgBox "b2 add office back"
           Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 2, 7 'Office 15 ref
           MsgBox "b2 add outlook back"
           Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 0, 0 'Outlook ref.
        End If
    End If
  
ITAExit:
     Exit Function

ITAError:
    'msgGeneralError "The system could not open due to Microsoft version issues - please contact your system support!"
    'Application.Quit
    'MsgBox Err.Number & " " & Err.Description
    'Resume Next
    'Resume ITAExit
End Function


Public Function justaddReferences()
'--------------------------------------------------------------------------------------------

On Error Resume Next 'GoTo ITAError

If SysCmd(acSysCmdAccessVer) = "16.0" Then
Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 2, 8 'Office 16 ref
Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 0, 0 'Outlook ref.
ElseIf SysCmd(acSysCmdAccessVer) = "15.0" Then
MsgBox "b2 add office back"
Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 2, 7 'Office 15 ref
MsgBox "b2 add outlook back"
Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 9, 5 'Outlook ref.
End If


ITAExit:
Exit Function

ITAError:
'msgGeneralError "The system could not open due to Microsoft version issues - please contact your system support!"
'Application.Quit
'MsgBox Err.Number & " " & Err.Description
'Resume Next
'Resume ITAExit
End Function[/code]
Attached File(s)
Attached File  test_reference_adding.zip ( 55.01K )Number of downloads: 2
 

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
LPurvis
post Jun 20 2017, 12:41 PM
Post#15


UtterAccess Editor
Posts: 16,086
Joined: 27-June 06
From: England (North East / South Yorks)


Hi

Just to highlight one obvious line:
>> I can add the references below to the Access 2013 Runtime application (on that different PC) - if the references for Office 16 were removed manually before I installed it.

To paraphrase the doctor whose patient says "It hurts when I lift my arm like this"...
Then don't send it with the references present. :-p

It was earlier in this thread that I first suggested shipping it is such a state.
The reason being that broken references can have a knock-on effect in a VBA project. (Causing simple, even built-in, VBA functions to fail.)

I often have a procedure in my applications which preps them for distribution before release. (Removes linked tables ready to pick up the new ones at the target site, sets any properties, or clears settings tables and could remove the potential problem references.)
Your startup code would then add them back in as it arrives on-site at the target anew.

Cheers

--------------------
Go to the top of the page
 
Louverril
post Jun 20 2017, 02:39 PM
Post#16



Posts: 456
Joined: 29-April 08



Hello Leigh,

Yes I had considered that, but the problem is once they have ran it the first time, the next time the references will already be loaded and so the autoexec code to load them again will error?

Or ???

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jun 20 2017, 02:40 PM
Post#17



Posts: 456
Joined: 29-April 08



PS:

In other words how would I test to bypass adding the references? I couldn't work out a way.

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jun 20 2017, 02:57 PM
Post#18



Posts: 456
Joined: 29-April 08



Didn't think that through - could have set a value in a local table and tested that. Mmmm.

Thanks

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jun 20 2017, 08:18 PM
Post#19



Posts: 456
Joined: 29-April 08



Well I made some progress :-)

This works! I had to also rearrange some of my ribbon code, and global variable setting in the code that run after this.

CODE
Public Function addReferences()

' NOTES:   Remember you can't reference the name if the reference is broken.
'          The 0,0 should pick the latest version installed on that machine - _
           this doesn't work for office on our PCs with multiple versions of Access (because of the runtime versions)

' TIP      If you want to add other references and you have Excel on the target machine but only Access runtime, _
           you can find teh GUIDs through EXCEL

' LIMITATIONS: Does not cover the 64 GUIDS _
               Makes an assumption about the missing references _
               Use must deliver the system will the references present - in order to check if they are broken _
               and force a re-add of the correct version. _
               Only works with Office 15.0 (2013) and 16.0 (2016)

'-------------------------------------------------------------------------------------------
    Dim strSQL As String

        If DLookup("LI_ReferencesAdded", "tblLocalInfo") <> 1 Then
        If SysCmd(acSysCmdAccessVer) = "16.0" Then
            Application.References.AddFromGuid "{00020430-0000-0000-C000-000000000046}", 2, 0 'StOLE OLE Automation
            Application.References.AddFromGuid "{0002E157-0000-0000-C000-000000000046}", 5, 3 'VBIDE4 Applications Extensibility
            Application.References.AddFromGuid "{4AC9E1DA-5BAD-4AC7-86E3-24F4CDCECA28}", 12, 0 'DAO Ref
            Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 2, 8 'Office 16 ref
            Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 0, 0 'Outlook ref.

        ElseIf SysCmd(acSysCmdAccessVer) = "15.0" Then
            Application.References.AddFromGuid "{00020430-0000-0000-C000-000000000046}", 2, 0 'StOLE OLE Automation
            Application.References.AddFromGuid "{0002E157-0000-0000-C000-000000000046}", 5, 3 'VBIDE4 Applications Extensibility
            Application.References.AddFromGuid "{4AC9E1DA-5BAD-4AC7-86E3-24F4CDCECA28}", 12, 0 'DAO Ref
            Application.References.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 2, 7 'Office 15 ref
            Application.References.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 9, 5 'Outlook ref.
        End If
        
        strSQL = "UPDATE tblLocalInfo SET tblLocalInfo.LI_ReferencesAdded = " & 1
        CurrentDb.Execute strSQL

    End If

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jun 20 2017, 08:25 PM
Post#20



Posts: 456
Joined: 29-April 08



Correction - in fact I had to remove the ribbon loading.

I was getting callbackonload errors.

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search
RSSSearch   Top   Lo-Fi    18th December 2017 - 05:22 PM