{"id":3159,"date":"2024-06-08T00:00:43","date_gmt":"2024-06-07T15:00:43","guid":{"rendered":"http:\/\/anada.cloudfree.jp\/?p=3159"},"modified":"2024-06-04T13:24:48","modified_gmt":"2024-06-04T04:24:48","slug":"excelvba%e8%a6%9a%e6%9b%b8-vba%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%83%ad%e3%83%83%e3%82%af%e8%a7%a3%e9%99%a4","status":"publish","type":"post","link":"http:\/\/anada.cloudfree.jp\/?p=3159","title":{"rendered":"ExcelVBA\u899a\u66f8 VBA\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30ed\u30c3\u30af\u89e3\u9664"},"content":{"rendered":"<p>\u3053\u3093\u306a\u3093\u3067\u89e3\u9664\u3067\u304d\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u3063\u3066\u3001\u306a\u3093\u306e\u305f\u3081\u306b\u3064\u3044\u3066\u3044\u308b\u306e\u3084\u3089\u30fb\u30fb\u30fb<br \/>\n\u3068\u601d\u3063\u305f\u308a\u3059\u308b\u304c\u3001\u307e\u3041\u30d1\u30b9\u30ef\u30fc\u30c9\u5fd8\u308c\u305f\u3068\u304d\u306f\u975e\u5e38\u306b\u3042\u308a\u304c\u305f\u3044\u306e\u3060\u3002<\/p>\n<p>\u53c2\u8003URL<br \/>\n<a href=\"https:\/\/www.saka-en.com\/office\/vba-macro-password-unlock\/#google_vignette\" target=\"_blank\" rel=\"noopener\">\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u5236\u4f5c\u306e\u30b5\u30ab\u30a8\u30f3\u300cExcel VBA \u30de\u30af\u30ed \u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u89e3\u9664\u3059\u308b\u65b9\u6cd5 32\u30d3\u30c3\u30c8 64\u30d3\u30c3\u30c8\u300d<\/a><\/p>\n<p>\u3053\u3053\u304b\u3089\u306f64bit\u7248\u3060\u3051\u8ee2\u8f09<br \/>\n\uff08LongPtr\u3092Long\u306b\u3001PtrSafe\u3092\u524a\u9664\u3059\u308c\u307032bit\u7248\u306b\u306a\u308b\uff09<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nOption Explicit\r\n  \r\nPrivate Const PAGE_EXECUTE_READWRITE = &amp;H40\r\n  \r\nPrivate Declare PtrSafe Sub MoveMemory Lib &quot;kernel32&quot; Alias &quot;RtlMoveMemory&quot; (Destination As LongPtr, Source As LongPtr, ByVal Length As LongPtr)\r\nPrivate Declare PtrSafe Function VirtualProtect Lib &quot;kernel32&quot; (lpAddress As LongPtr, ByVal dwSize As LongPtr, ByVal flNewProtect As LongPtr, lpflOldProtect As LongPtr) As LongPtr\r\nPrivate Declare PtrSafe Function GetModuleHandleA Lib &quot;kernel32&quot; (ByVal lpModuleName As String) As LongPtr\r\nPrivate Declare PtrSafe Function GetProcAddress Lib &quot;kernel32&quot; (ByVal hModule As LongPtr, ByVal lpProcName As String) As LongPtr\r\nPrivate Declare PtrSafe Function DialogBoxParam Lib &quot;user32&quot; Alias &quot;DialogBoxParamA&quot; (ByVal hInstance As LongPtr, ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer\r\n\r\nDim HookBytes(0 To 5) As Byte\r\nDim OriginBytes(0 To 5) As Byte\r\nDim pFunc As LongPtr\r\nDim Flag As Boolean\r\n  \r\nPrivate Function GetPtr(ByVal Value As LongPtr) As LongPtr\r\n  GetPtr = Value\r\nEnd Function\r\n  \r\nPrivate Sub RecoverBytes()\r\n  If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6\r\nEnd Sub\r\n  \r\nPublic Function Hook() As Boolean\r\n  Dim TmpBytes(0 To 5) As Byte\r\n  Dim p As LongPtr\r\n  Dim OriginProtect As LongPtr\r\n  \r\n  Hook = False\r\n  pFunc = GetProcAddress(GetModuleHandleA(&quot;user32.dll&quot;), &quot;DialogBoxParamA&quot;)\r\n  If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) &lt;&gt; 0 Then\r\n    MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6\r\n    If TmpBytes(0) &lt;&gt; &amp;H68 Then\r\n      MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6\r\n      p = GetPtr(AddressOf MyDialogBoxParam)\r\n      HookBytes(0) = &amp;H68\r\n      MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4\r\n      HookBytes(5) = &amp;HC3\r\n      MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6\r\n      Flag = True\r\n      Hook = True\r\n    End If\r\n  End If\r\nEnd Function\r\n  \r\nPrivate Function MyDialogBoxParam(ByVal hInstance As LongPtr, ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer\r\n  If pTemplateName = 4070 Then\r\n    MyDialogBoxParam = 1\r\n  Else\r\n    RecoverBytes\r\n    MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, hWndParent, lpDialogFunc, dwInitParam)\r\n    Hook\r\n  End If\r\nEnd Function\r\n  \r\nPublic Sub VBAProject\u30d1\u30b9\u30ef\u30fc\u30c9\u89e3\u9664()\r\n  If Hook Then\r\n    MsgBox &quot;VBAProject\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u89e3\u9664\u6210\u529f\uff01&quot;, vbInformation, &quot;Congratulations&quot;\r\n  End If\r\nEnd Sub\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306a\u3093\u3067\u89e3\u9664\u3067\u304d\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u3063\u3066\u3001\u306a\u3093\u306e\u305f\u3081\u306b\u3064\u3044\u3066\u3044\u308b\u306e\u3084\u3089\u30fb\u30fb\u30fb \u3068\u601d\u3063\u305f\u308a\u3059\u308b\u304c\u3001\u307e\u3041\u30d1\u30b9\u30ef\u30fc\u30c9\u5fd8\u308c\u305f\u3068\u304d\u306f\u975e\u5e38\u306b\u3042\u308a\u304c\u305f\u3044\u306e\u3060\u3002 \u53c2\u8003URL \u30db\u30fc\u30e0\u30da\u30fc\u30b8\u5236\u4f5c\u306e\u30b5\u30ab\u30a8\u30f3\u300cExcel VBA \u30de\u30af\u30ed \u30d1\u30b9\u30ef\u30fc\u30c9\u3092 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-3159","post","type-post","status-publish","format-standard","hentry","category-excelvba"],"_links":{"self":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/3159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3159"}],"version-history":[{"count":1,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/3159\/revisions"}],"predecessor-version":[{"id":3160,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/3159\/revisions\/3160"}],"wp:attachment":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3159"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}