Can anyone configure this code to work with office xp

G

Guest

Guest
Option Compare Text
Option Explicit

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal lhKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal lhKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal lhKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const REG_HEX As Long = 4 'Hex Key
Private Const HKEY_CURRENT_USER As Long = &H80000001


'Purpose : Enables or disables the macro virus alert by altering the security level in the registry.
'Inputs : lSecurityLevel 1, sets security to "Low" (disable virus alerts)
' 2, sets security to "Medium"
' 3, sets security to "High"

Function MacroSecurity2000(lSecurityLevel As Long) As Boolean
Dim sData As String, lRet As Long
Const csPath = "SoftwareMicrosoftOffice9.0ExcelSecurity", csValue = "Level"

If lSecurityLevel <= 3 And lSecurityLevel > 0 Then
On Error GoTo ErrFailed
RegCreateKey HKEY_CURRENT_USER, csPath, lRet
RegSetValueEx lRet, csValue, 0, REG_HEX, lSecurityLevel, 1 '4
RegCloseKey lRet
MacroSecurity2000 = True
End If

Exit Function
ErrFailed:
MacroSecurity2000 = False
End Function


'Purpose : Enables or disables the macro virus alert.
'Inputs : bDisableVirusChecking True, disables macro security protection
' False, enables macro security protection


Function MacroSecurity97(bDisableVirusChecking As Boolean) As Boolean
Dim lData As Long, lRet As Long
Const csPath = "SoftwareMicrosoftOffice8.0ExcelMicrosoft Excel", csValue = "Options6"

On Error GoTo ErrFailed
If bDisableVirusChecking Then
lData = 0 'Disabled
Else
lData = 8 'Enabled
End If
RegCreateKey HKEY_CURRENT_USER, csPath, lRet
RegSetValueEx lRet, csValue, 0, REG_HEX, lData, 4
RegCloseKey lRet
MacroSecurity97 = True
Exit Function
ErrFailed:
MacroSecurity97 = False
End Function
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
The top code applies the the registartion key
for excel97...there is a bit you can set that
disables the enable macro prompt.
I'm not sure of the bit for XP as I don't
use office XP. But the registration path
you should be able to get from the Regeditor

Try running the 2000 version for XP ??
Note afetr running this you will have to close then reopen excel for it to take effect.


Ivan
 
Upvote 0

Forum statistics

Threads
1,213,539
Messages
6,114,221
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top