1cdf0e10cSrcweirAttribute VB_Name = "Office10Issues"
2*e76eebc6SAndrew Rist'*************************************************************************
3*e76eebc6SAndrew Rist'
4*e76eebc6SAndrew Rist'  Licensed to the Apache Software Foundation (ASF) under one
5*e76eebc6SAndrew Rist'  or more contributor license agreements.  See the NOTICE file
6*e76eebc6SAndrew Rist'  distributed with this work for additional information
7*e76eebc6SAndrew Rist'  regarding copyright ownership.  The ASF licenses this file
8*e76eebc6SAndrew Rist'  to you under the Apache License, Version 2.0 (the
9*e76eebc6SAndrew Rist'  "License"); you may not use this file except in compliance
10*e76eebc6SAndrew Rist'  with the License.  You may obtain a copy of the License at
11*e76eebc6SAndrew Rist'
12*e76eebc6SAndrew Rist'    http://www.apache.org/licenses/LICENSE-2.0
13*e76eebc6SAndrew Rist'
14*e76eebc6SAndrew Rist'  Unless required by applicable law or agreed to in writing,
15*e76eebc6SAndrew Rist'  software distributed under the License is distributed on an
16*e76eebc6SAndrew Rist'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*e76eebc6SAndrew Rist'  KIND, either express or implied.  See the License for the
18*e76eebc6SAndrew Rist'  specific language governing permissions and limitations
19*e76eebc6SAndrew Rist'  under the License.
20*e76eebc6SAndrew Rist'
21*e76eebc6SAndrew Rist'*************************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweir'Disable Option Explicit so this will compile on earlier Office versions
24cdf0e10cSrcweir'Option Explicit
25cdf0e10cSrcweirPublic Declare Function RegCloseKey Lib "advapi32.dll" _
26cdf0e10cSrcweir    (ByVal hKey As Long) As Long
27cdf0e10cSrcweirPublic Declare Function RegQueryValueEx Lib "advapi32.dll" _
28cdf0e10cSrcweir    Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
29cdf0e10cSrcweir    ByVal lpReserved As Long, lpType As Long, lpData As Any, _
30cdf0e10cSrcweir    lpcbData As Long) As Long
31cdf0e10cSrcweirPublic Declare Function RegSetValueEx Lib "advapi32.dll" _
32cdf0e10cSrcweir    Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
33cdf0e10cSrcweir    ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, _
34cdf0e10cSrcweir    ByVal cbData As Long) As Long
35cdf0e10cSrcweirPublic Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal _
36cdf0e10cSrcweir    hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass _
37cdf0e10cSrcweir    As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes _
38cdf0e10cSrcweir    As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
39cdf0e10cSrcweirPublic Declare Function RegOpenKey Lib "advapi32.dll" _
40cdf0e10cSrcweir    Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, _
41cdf0e10cSrcweir    phkResult As Long) As Long
42cdf0e10cSrcweirPublic Declare Function RegCreateKey Lib "advapi32.dll" _
43cdf0e10cSrcweir    Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, _
44cdf0e10cSrcweir    phkResult As Long) As Long
45cdf0e10cSrcweirPublic Declare Function RegDeleteValue Lib "advapi32.dll" _
46cdf0e10cSrcweir    Alias "RegDeleteValueA" (ByVal hKey As Long, _
47cdf0e10cSrcweir    ByVal lpValueName As String) As Long
48cdf0e10cSrcweirPublic Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal _
49cdf0e10cSrcweir    hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired _
50cdf0e10cSrcweir    As Long, phkResult As Long) As Long
51cdf0e10cSrcweir
52cdf0e10cSrcweirType SECURITY_ATTRIBUTES
53cdf0e10cSrcweir    nLength As Long
54cdf0e10cSrcweir    lpSecurityDescriptor As Long
55cdf0e10cSrcweir    bInheritHandle As Long
56cdf0e10cSrcweirEnd Type
57cdf0e10cSrcweir
58cdf0e10cSrcweirEnum RegHive
59cdf0e10cSrcweir    'HKEY_CLASSES_ROOT = &H80000000
60cdf0e10cSrcweir    HK_CR = &H80000000
61cdf0e10cSrcweir    HKEY_CURRENT_USER = &H80000001
62cdf0e10cSrcweir    HK_CU = &H80000001
63cdf0e10cSrcweir    HKEY_LOCAL_MACHINE = &H80000002
64cdf0e10cSrcweir    HK_LM = &H80000002
65cdf0e10cSrcweir    HKEY_USERS = &H80000003
66cdf0e10cSrcweir    HK_US = &H80000003
67cdf0e10cSrcweir    HKEY_CURRENT_CONFIG = &H80000005
68cdf0e10cSrcweir    HK_CC = &H80000005
69cdf0e10cSrcweir    HKEY_DYN_DATA = &H80000006
70cdf0e10cSrcweir    HK_DD = &H80000006
71cdf0e10cSrcweirEnd Enum
72cdf0e10cSrcweir
73cdf0e10cSrcweirEnum RegType
74cdf0e10cSrcweir    REG_SZ = 1 'Unicode nul terminated string
75cdf0e10cSrcweir    REG_BINARY = 3 'Free form binary
76cdf0e10cSrcweir    REG_DWORD = 4 '32-bit number
77cdf0e10cSrcweirEnd Enum
78cdf0e10cSrcweir
79cdf0e10cSrcweirConst ERROR_SUCCESS = 0
80cdf0e10cSrcweirConst KEY_WRITE = &H20006
81cdf0e10cSrcweirConst APP_EXCEL = "Excel"
82cdf0e10cSrcweirConst APP_WORD = "Word"
83cdf0e10cSrcweirConst APP_PP = "PowerPoint"
84cdf0e10cSrcweir
85cdf0e10cSrcweirPublic Function CreateRegKey(hKey As RegHive, strPath As String)
86cdf0e10cSrcweir    On Error GoTo HandleErrors
87cdf0e10cSrcweir    Dim currentFunctionName As String
88cdf0e10cSrcweir    currentFunctionName = "CreateRegKey"
89cdf0e10cSrcweir
90cdf0e10cSrcweir    Dim heKey As Long
91cdf0e10cSrcweir    Dim secattr As SECURITY_ATTRIBUTES  ' security settings for the key
92cdf0e10cSrcweir    Dim subkey As String        ' name of the subkey to create or open
93cdf0e10cSrcweir    Dim neworused As Long       ' receives flag for if the key was created or opened
94cdf0e10cSrcweir    Dim stringbuffer As String  ' the string to put into the registry
95cdf0e10cSrcweir    Dim retval As Long          ' return value
96cdf0e10cSrcweir
97cdf0e10cSrcweir    ' Set the name of the new key and the default security settings
98cdf0e10cSrcweir    secattr.nLength = Len(secattr)
99cdf0e10cSrcweir    secattr.lpSecurityDescriptor = 0
100cdf0e10cSrcweir    secattr.bInheritHandle = 1
101cdf0e10cSrcweir
102cdf0e10cSrcweir     retval = RegCreateKeyEx(hKey, strPath, 0, "", 0, KEY_WRITE, _
103cdf0e10cSrcweir        secattr, heKey, neworused)
104cdf0e10cSrcweir    If retval = 0 Then
105cdf0e10cSrcweir        retval = RegCloseKey(hKey)
106cdf0e10cSrcweir        Exit Function
107cdf0e10cSrcweir    End If
108cdf0e10cSrcweir
109cdf0e10cSrcweirHandleErrors:
110cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
111cdf0e10cSrcweirEnd Function
112cdf0e10cSrcweir
113cdf0e10cSrcweirPublic Function CreateRegKey2(hKey As RegHive, strPath As String) As Long
114cdf0e10cSrcweir    On Error GoTo HandleErrors
115cdf0e10cSrcweir    Dim currentFunctionName As String
116cdf0e10cSrcweir    currentFunctionName = "CreateRegKey"
117cdf0e10cSrcweir    CreateRegKey2 = 0
118cdf0e10cSrcweir
119cdf0e10cSrcweir    Dim heKey As Long
120cdf0e10cSrcweir    Dim secattr As SECURITY_ATTRIBUTES  ' security settings for the key
121cdf0e10cSrcweir    Dim subkey As String        ' name of the subkey to create or open
122cdf0e10cSrcweir    Dim neworused As Long       ' receives flag for if the key was created or opened
123cdf0e10cSrcweir    Dim stringbuffer As String  ' the string to put into the registry
124cdf0e10cSrcweir    Dim retval As Long          ' return value
125cdf0e10cSrcweir
126cdf0e10cSrcweir    ' Set the name of the new key and the default security settings
127cdf0e10cSrcweir    secattr.nLength = Len(secattr)
128cdf0e10cSrcweir    secattr.lpSecurityDescriptor = 0
129cdf0e10cSrcweir    secattr.bInheritHandle = 1
130cdf0e10cSrcweir
131cdf0e10cSrcweir    retval = RegCreateKeyEx(hKey, strPath, 0, "", 0, KEY_WRITE, _
132cdf0e10cSrcweir        secattr, heKey, neworused)
133cdf0e10cSrcweir    If retval = ERROR_SUCCESS Then
134cdf0e10cSrcweir        CreateRegKey2 = heKey
135cdf0e10cSrcweir        Exit Function
136cdf0e10cSrcweir    End If
137cdf0e10cSrcweir
138cdf0e10cSrcweirFinalExit:
139cdf0e10cSrcweir    Exit Function
140cdf0e10cSrcweir
141cdf0e10cSrcweirHandleErrors:
142cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
143cdf0e10cSrcweir    CreateRegKey2 = 0
144cdf0e10cSrcweir    GoTo FinalExit
145cdf0e10cSrcweirEnd Function
146cdf0e10cSrcweir
147cdf0e10cSrcweir
148cdf0e10cSrcweirPublic Function GetRegLong(ByVal hKey As RegHive, ByVal strPath As String, ByVal strValue As String) As Long
149cdf0e10cSrcweir    On Error GoTo HandleErrors
150cdf0e10cSrcweir    Dim currentFunctionName As String
151cdf0e10cSrcweir    currentFunctionName = "GetRegLong"
152cdf0e10cSrcweir
153cdf0e10cSrcweir    Dim lRegResult As Long
154cdf0e10cSrcweir    Dim lValueType As Long
155cdf0e10cSrcweir    Dim lBuffer As Long
156cdf0e10cSrcweir    Dim lDataBufferSize As Long
157cdf0e10cSrcweir    Dim hCurKey As Long
158cdf0e10cSrcweir
159cdf0e10cSrcweir    GetRegLong = 0
160cdf0e10cSrcweir    lRegResult = RegOpenKey(hKey, strPath, hCurKey)
161cdf0e10cSrcweir    lDataBufferSize = 4 '4 bytes = 32 bits = long
162cdf0e10cSrcweir
163cdf0e10cSrcweir    lRegResult = RegQueryValueEx(hCurKey, strValue, 0, REG_DWORD, lBuffer, lDataBufferSize)
164cdf0e10cSrcweir    If lRegResult = ERROR_SUCCESS Then
165cdf0e10cSrcweir        GetRegLong = lBuffer
166cdf0e10cSrcweir    End If
167cdf0e10cSrcweir        lRegResult = RegCloseKey(hCurKey)
168cdf0e10cSrcweir        Exit Function
169cdf0e10cSrcweir
170cdf0e10cSrcweirHandleErrors:
171cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
172cdf0e10cSrcweirEnd Function
173cdf0e10cSrcweir
174cdf0e10cSrcweirPublic Function SaveRegLong(ByVal hKey As RegHive, ByVal strPath As String, ByVal strValue As String, ByVal lData As Long)
175cdf0e10cSrcweir    On Error GoTo HandleErrors
176cdf0e10cSrcweir    Dim currentFunctionName As String
177cdf0e10cSrcweir    currentFunctionName = "SaveRegLong"
178cdf0e10cSrcweir
179cdf0e10cSrcweir    Const NumofByte = 4
180cdf0e10cSrcweir    Dim hCurKey As Long
181cdf0e10cSrcweir    Dim lRegResult As Long
182cdf0e10cSrcweir
183cdf0e10cSrcweir    lRegResult = RegCreateKey(hKey, strPath, hCurKey)
184cdf0e10cSrcweir    lRegResult = RegSetValueEx(hCurKey, strValue, 0&, REG_DWORD, lData, NumofByte)
185cdf0e10cSrcweir    If lRegResult = ERROR_SUCCESS Then
186cdf0e10cSrcweir        lRegResult = RegCloseKey(hCurKey)
187cdf0e10cSrcweir        Exit Function
188cdf0e10cSrcweir    End If
189cdf0e10cSrcweir
190cdf0e10cSrcweirHandleErrors:
191cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
192cdf0e10cSrcweirEnd Function
193cdf0e10cSrcweir
194cdf0e10cSrcweir
195cdf0e10cSrcweirPublic Function GiveAccessToMacroProject(application As String, sVersion As String, oldvalue As Long) As Boolean
196cdf0e10cSrcweir    On Error GoTo HandleErrors
197cdf0e10cSrcweir    Dim currentFunctionName As String
198cdf0e10cSrcweir    currentFunctionName = "SaveRegLong"
199cdf0e10cSrcweir    GiveAccessToMacroProject = False
200cdf0e10cSrcweir
201cdf0e10cSrcweir    Const OfficePath = "Software\Policies\Microsoft\Office\"
202cdf0e10cSrcweir    Const security = "\Security"
203cdf0e10cSrcweir    Const AccessVBOM = "AccessVBOM"
204cdf0e10cSrcweir    Const AccessVBOMValue = 1
205cdf0e10cSrcweir    Dim subpath As String
206cdf0e10cSrcweir    Dim RegistryValue As Long
207cdf0e10cSrcweir
208cdf0e10cSrcweir    subpath = OfficePath & sVersion & "\" & application & security
209cdf0e10cSrcweir    CreateRegKey HKEY_CURRENT_USER, subpath
210cdf0e10cSrcweir    RegistryValue = GetRegLong(HKEY_CURRENT_USER, subpath, AccessVBOM)
211cdf0e10cSrcweir    oldvalue = RegistryValue
212cdf0e10cSrcweir    SaveRegLong HKEY_CURRENT_USER, subpath, AccessVBOM, AccessVBOMValue
213cdf0e10cSrcweir    GiveAccessToMacroProject = True
214cdf0e10cSrcweir    Exit Function
215cdf0e10cSrcweir
216cdf0e10cSrcweirHandleErrors:
217cdf0e10cSrcweir    GiveAccessToMacroProject = False
218cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
219cdf0e10cSrcweirEnd Function
220cdf0e10cSrcweir
221cdf0e10cSrcweirPublic Function SetDefaultRegValue(application As String, sVersion As String, sValue As Long)
222cdf0e10cSrcweir    On Error GoTo HandleErrors
223cdf0e10cSrcweir    Dim currentFunctionName As String
224cdf0e10cSrcweir    currentFunctionName = "SaveRegLong"
225cdf0e10cSrcweir
226cdf0e10cSrcweir    Const OfficePath = "Software\Policies\Microsoft\Office\"
227cdf0e10cSrcweir    Const security = "\Security"
228cdf0e10cSrcweir    Const AccessVBOM = "AccessVBOM"
229cdf0e10cSrcweir    Dim subpath As String
230cdf0e10cSrcweir
231cdf0e10cSrcweir    subpath = OfficePath & sVersion & "\" & application & security
232cdf0e10cSrcweir    SaveRegLong HKEY_CURRENT_USER, subpath, AccessVBOM, sValue
233cdf0e10cSrcweir    Exit Function
234cdf0e10cSrcweir
235cdf0e10cSrcweirHandleErrors:
236cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
237cdf0e10cSrcweirEnd Function
238cdf0e10cSrcweirPublic Function DeleteRegValue(application As String, sVersion As String)
239cdf0e10cSrcweir    On Error GoTo HandleErrors
240cdf0e10cSrcweir    Dim currentFunctionName As String
241cdf0e10cSrcweir    currentFunctionName = "SaveRegLong"
242cdf0e10cSrcweir
243cdf0e10cSrcweir    Const OfficePath = "Software\Policies\Microsoft\Office\"
244cdf0e10cSrcweir    Const security = "\Security"
245cdf0e10cSrcweir    Const AccessVBOM = "AccessVBOM"
246cdf0e10cSrcweir    Dim subpath As String
247cdf0e10cSrcweir    Dim retval As Long
248cdf0e10cSrcweir    Dim hKey As Long
249cdf0e10cSrcweir
250cdf0e10cSrcweir    subpath = OfficePath & sVersion & "\" & application & security
251cdf0e10cSrcweir    retval = RegOpenKeyEx(HKEY_CURRENT_USER, subpath, 0, KEY_WRITE, hKey)
252cdf0e10cSrcweir    If retval = ERROR_SUCCESS Then
253cdf0e10cSrcweir        retval = RegDeleteValue(hKey, AccessVBOM)
254cdf0e10cSrcweir        retval = RegCloseKey(hKey)
255cdf0e10cSrcweir        Exit Function
256cdf0e10cSrcweir    End If
257cdf0e10cSrcweir
258cdf0e10cSrcweirHandleErrors:
259cdf0e10cSrcweir    WriteDebug currentFunctionName & " : " & Err.Number & " " & Err.Description & " " & Err.Source
260cdf0e10cSrcweirEnd Function
261cdf0e10cSrcweir
262cdf0e10cSrcweirPublic Function CheckForAccesToWordVBProject1(wrd As Word.application, RestoreValue As Long) As Boolean
263cdf0e10cSrcweir    On Error Resume Next
264cdf0e10cSrcweir    CheckForAccesToWordVBProject1 = True
265cdf0e10cSrcweir    RestoreValue = -1
266cdf0e10cSrcweir    If val(wrd.Version) < 10# Then Exit Function
267cdf0e10cSrcweir
268cdf0e10cSrcweir    Set myProject = wrd.ActiveDocument.VBProject
269cdf0e10cSrcweir    If Err.Number <> 0 Then
270cdf0e10cSrcweir        Dim RegValue As Long
271cdf0e10cSrcweir        If GiveAccessToMacroProject(APP_WORD, wrd.Version, RegValue) Then
272cdf0e10cSrcweir            CheckForAccesToWordVBProject1 = True
273cdf0e10cSrcweir            RestoreValue = RegValue
274cdf0e10cSrcweir        Else
275cdf0e10cSrcweir            CheckForAccesToWordVBProject1 = False
276cdf0e10cSrcweir        End If
277cdf0e10cSrcweir    End If
278cdf0e10cSrcweir
279cdf0e10cSrcweirEnd Function
280cdf0e10cSrcweirPublic Function CheckForAccesToWordVBProject(wrd As Word.application) As Boolean
281cdf0e10cSrcweir    On Error Resume Next
282cdf0e10cSrcweir    CheckForAccesToWordVBProject = True
283cdf0e10cSrcweir    If val(wrd.Version) < 10# Then Exit Function
284cdf0e10cSrcweir
285cdf0e10cSrcweir    Set myProject = wrd.ActiveDocument.VBProject
286cdf0e10cSrcweir    If Err.Number <> 0 Then
287cdf0e10cSrcweir        CheckForAccesToWordVBProject = False
288cdf0e10cSrcweir    End If
289cdf0e10cSrcweir
290cdf0e10cSrcweirEnd Function
291cdf0e10cSrcweirPublic Function CheckForAccesToExcelVBProject1(xl As Excel.application, RestoreValue As Long) As Boolean
292cdf0e10cSrcweir    On Error Resume Next
293cdf0e10cSrcweir    CheckForAccesToExcelVBProject1 = True
294cdf0e10cSrcweir    RestoreValue = -1
295cdf0e10cSrcweir    If val(xl.Version) < 10# Then Exit Function
296cdf0e10cSrcweir
297cdf0e10cSrcweir    Dim displayAlerts As Boolean
298cdf0e10cSrcweir    displayAlerts = xl.displayAlerts
299cdf0e10cSrcweir    xl.displayAlerts = False
300cdf0e10cSrcweir    Set myProject = xl.ActiveWorkbook.VBProject
301cdf0e10cSrcweir    If Err.Number <> 0 Then
302cdf0e10cSrcweir        Dim RegValue As Long
303cdf0e10cSrcweir        If GiveAccessToMacroProject(APP_EXCEL, xl.Version, RegValue) Then
304cdf0e10cSrcweir            CheckForAccesToExcelVBProject1 = True
305cdf0e10cSrcweir            RestoreValue = RegValue
306cdf0e10cSrcweir        Else
307cdf0e10cSrcweir            CheckForAccesToExcelVBProject1 = False
308cdf0e10cSrcweir        End If
309cdf0e10cSrcweir    End If
310cdf0e10cSrcweir    xl.displayAlerts = displayAlerts
311cdf0e10cSrcweir
312cdf0e10cSrcweirEnd Function
313cdf0e10cSrcweirPublic Function CheckForAccesToExcelVBProject(xl As Excel.application) As Boolean
314cdf0e10cSrcweir    On Error Resume Next
315cdf0e10cSrcweir    CheckForAccesToExcelVBProject = True
316cdf0e10cSrcweir    If val(xl.Version) < 10# Then Exit Function
317cdf0e10cSrcweir
318cdf0e10cSrcweir    Dim displayAlerts As Boolean
319cdf0e10cSrcweir    displayAlerts = xl.displayAlerts
320cdf0e10cSrcweir    xl.displayAlerts = False
321cdf0e10cSrcweir    Set myProject = xl.ActiveWorkbook.VBProject
322cdf0e10cSrcweir    If Err.Number <> 0 Then
323cdf0e10cSrcweir        CheckForAccesToExcelVBProject = False
324cdf0e10cSrcweir    End If
325cdf0e10cSrcweir    xl.displayAlerts = displayAlerts
326cdf0e10cSrcweir
327cdf0e10cSrcweirEnd Function
328cdf0e10cSrcweirPublic Function CheckForAccesToPPVBProject1(pp As PowerPoint.application, pres As PowerPoint.Presentation, RestoreValue As Long) As Boolean
329cdf0e10cSrcweir    On Error Resume Next
330cdf0e10cSrcweir    CheckForAccesToPPVBProject1 = True
331cdf0e10cSrcweir    RestoreValue = -1
332cdf0e10cSrcweir    If val(pp.Version) < 10# Then Exit Function
333cdf0e10cSrcweir
334cdf0e10cSrcweir    Set myProject = pres.VBProject
335cdf0e10cSrcweir    If Err.Number <> 0 Then
336cdf0e10cSrcweir        Dim RegValue As Long
337cdf0e10cSrcweir        If GiveAccessToMacroProject(APP_PP, pp.Version, RegValue) Then
338cdf0e10cSrcweir            CheckForAccesToPPVBProject1 = True
339cdf0e10cSrcweir            RestoreValue = RegValue
340cdf0e10cSrcweir        Else
341cdf0e10cSrcweir            CheckForAccesToPPVBProject1 = False
342cdf0e10cSrcweir        End If
343cdf0e10cSrcweir    End If
344cdf0e10cSrcweirEnd Function
345cdf0e10cSrcweir
346cdf0e10cSrcweirPublic Function CheckForAccesToPPVBProject(pp As PowerPoint.application, pres As PowerPoint.Presentation) As Boolean
347cdf0e10cSrcweir    On Error Resume Next
348cdf0e10cSrcweir    CheckForAccesToPPVBProject = True
349cdf0e10cSrcweir    If val(pp.Version) < 10# Then Exit Function
350cdf0e10cSrcweir
351cdf0e10cSrcweir    Set myProject = pres.VBProject
352cdf0e10cSrcweir    If Err.Number <> 0 Then
353cdf0e10cSrcweir        CheckForAccesToPPVBProject = False
354cdf0e10cSrcweir    End If
355cdf0e10cSrcweirEnd Function
356