السلام عليكم ورحمة الله وبركاته
إخواني وأحبابي في الله
الكود التالي يفيد في عملية ضبط البروكسي باستخدام الـ VBA ، حيث يسمح بالتعديل في الريجستري ، وبالكود خيارات متعددة
ها هو الكود بين أيديكم
CODE
#If VBA7 Then
Private Declare PtrSafe Function InternetSetOptionA Lib "wininet.dll" (ByVal hInternet As Long, ByVal lOption As Long, ByVal sBuffer As String, ByVal lBufferLength As Long) As Integer
#Else
Private Declare Function InternetSetOptionA Lib "wininet.dll" (ByVal hInternet As Long, ByVal lOption As Long, ByVal sBuffer As String, ByVal lBufferLength As Long) As Integer
#End If
Sub Change_Proxy_Settings_Using_VBA()
Dim vUser1, vUser2, ans%
ans = MsgBox("To Enable Proxy Settings Click 'Yes'." & Chr(13) & "To Disable Proxy Settings Click 'No'", vbYesNoCancel + vbQuestion)
If ans = vbYes Then
vUser1 = InputBox("Enter The Proxy Server You Want To Use.", "Proxy Server", "http://techno7asry.com:8080")
If vUser1 = "" Then Exit Sub
Rem Proxy Server Exceptions
MsgBox "The URLs You Would Like To Override Should Be In Cell A1. Use Semi-Colons (;) To Separate Entries", 64
vUser2 = ActiveSheet.Range("A1").Value
ProxySettings True, vUser1, vUser2
ElseIf ans = vbNo Then
ProxySettings False
Else
Exit Sub
End If
End Sub
Sub ProxySettings(bEnable As Boolean, Optional sProxyServer, Optional sProxyOverride)
Dim objShell As Object, regPath$, regServer$, regOverride$, regEnable$
Set objShell = CreateObject("WScript.Shell")
InternetSetOptionA 0, 39, 0, 0
regPath$ = "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"
regServer = regPath$ & "ProxyServer"
regOverride = regPath$ & "ProxyOverride"
regEnable = regPath$ & "ProxyEnable"
If bEnable = False Then GoTo Skipper
objShell.RegWrite regServer, sProxyServer, "REG_SZ"
objShell.RegWrite regOverride, sProxyOverride & "<local>", "REG_SZ"
Skipper:
objShell.RegWrite regEnable, IIf(bEnable, "1", "0"), "REG_DWORD"
MsgBox "Proxy Is " & IIf(bEnable, "Enabled", "Disabled")
Shell "C:Program FilesInternet Exploreriexplore.exe -nohome", vbNormalFocus
End Sub
ولدعم صاحب الموضوع يرجى النقر على الرابط التالي للحصول على الكود
رابط الكود من هنا
إعداد / ياسر خليل أبو البراء