{"id":1886,"date":"2023-03-12T14:14:14","date_gmt":"2023-03-12T05:14:14","guid":{"rendered":"https:\/\/euc-access-excel-db.com\/tips\/?p=1886"},"modified":"2025-10-24T21:36:39","modified_gmt":"2025-10-24T12:36:39","slug":"power-query-refresh01","status":"publish","type":"post","link":"https:\/\/euc-access-excel-db.com\/tips\/ct07_se\/ct075012_xls2k_vba_tips\/power-query-refresh01","title":{"rendered":"\u2605ExcelVBA \uff5e \u30d1\u30ef\u30fc\u30af\u30a8\u30ea\uff08PowerQuery\uff09\u306e\u66f4\u65b0\u65b9\u6cd5\u3044\u308d\u3044\u308d"},"content":{"rendered":"<p>\u2605ExcelVBA \uff5e  \u30d1\u30ef\u30fc\u30af\u30a8\u30ea\uff08PowerQuery\uff09\u306e\u66f4\u65b0\u65b9\u6cd5\u3044\u308d\u3044\u308d<br \/>\n<SPAN>\u3000\u3000<\/SPAN><br \/>\n<span style=\"color: #ff0000;\">\u203b\u307e\u3060\u66f8\u304d\u304b\u3051\u3067\u3059\u3002\u3059\u307f\u307e\u305b\u3093\u3002<\/span><br \/>\n<span style=\"color: #ff0000;\">\u203b\u9593\u9055\u3063\u3066\u305f\u3089\u3059\u307f\u307e\u305b\u3093\u3002<\/span><br \/>\n<span style=\"color: #ff0000;\">\u203b\u30e1\u30e2\u66f8\u304d\u306a\u306e\u3067\u3001\u81ea\u5206\u3067\u3082\u610f\u5473\u4e0d\u660e\u306a\u7b87\u6240\u3082\u591a\u3044\u3067\u3059\u3002\u3054\u3081\u3093\u306a\u3055\u3044\u3002<\/span><br \/>\n<SPAN>\u3000\u3000<\/SPAN><br \/>\n<SPAN>\u3000\u3000<\/SPAN><\/p>\n<p>\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408\u3001<br \/>\nListObject\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff08\u203bQueryTable.BackgroundQuery\u304c\u3089\u307f\uff09\u3092\u4f7f\u3046\u65b9\u6cd5\u3084<br \/>\nWorkbookConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff08\u203bOLEDBConnection.BackgroundQuery\u304c\u3089\u307f\uff09\u3092\u4f7f\u3046\u65b9\u6cd5\u306a\u3069\u306e\u3001<br \/>\n\u8907\u6570\u306e\u66f4\u65b0\u65b9\u6cd5\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u304c\u3001<br \/>\n\u3069\u3061\u3089\u306e\u65b9\u6cd5\u3067\u3082\u3001\uff08\u300c\u4ef6\u6570\u304c\u591a\u3044\u5834\u5408\u300d\u3068\u304b\u3058\u3083\u306a\u304f\u3066\uff09\u3001<br \/>\n\u300c\u00d7\u00d7\u00d7.BackgroundQuery = False\u300d\u3092\u8a2d\u5b9a\u3057\u3055\u3048\u3059\u308c\u3070\u3001<br \/>\n\u30eb\u30fc\u30d7\u3067\u306eDoEvents\u3084WAIT\u306a\u3069\u306f\u4e0d\u8981\u3067\u3001\u666e\u901a\u306b\u5b8c\u4e86\u307e\u3067\u5f85\u3063\u3066\u304f\u308c\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u9006\u306b\u3001<br \/>\n\u300c\u00d7\u00d7\u00d7.BackgroundQuery = False\u300d\u3092\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3001<br \/>\n\u30eb\u30fc\u30d7\u3067\u306eDoEvents\u3042\u308b\u3044\u306fWAIT\u306a\u3069\u304c\u5fc5\u8981\u306b\u306a\u308b\u3088\u3046\u306a\u306e\u3067\u3059\u304c\u3001<br \/>\n\u30d5\u30ea\u30fc\u30ba\u3057\u3066\u3057\u307e\u3063\u3066\u9032\u307f\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u3044\u3061\u304a\u3046\u3001\u3053\u3061\u3089\u3067\u306f\u4ee5\u4e0b\u306e\u300c\u2605(01) \u300d\u300c\u2605(02) \u300d\u306e\u3044\u305a\u308c\u304b\u306e\u30b3\u30fc\u30c9\u3067\u66f4\u65b0\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u8907\u6570\u306e\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u66f4\u65b0\u3082\u30011\u3064\u76ee\u30012\u3064\u76ee\u3001\uff13\u3064\u76ee\u30fb\u30fb\u30fb\u30fb\u306a\u3069\u3001<br \/>\n\u305d\u308c\u305e\u308c\u306b\u3001\u300c\u00d7\u00d7\u00d7.BackgroundQuery = False\u300d\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u3051\u3070\u3001<br \/>\n\u305d\u308c\u305e\u308c\u3001\u81ea\u52d5\u7684\u306b\u5f85\u3063\u3066\u304f\u308c\u3066\u3001\u6b63\u5e38\u66f4\u65b0\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d<br \/>\n\u2605(01)<br \/>\nListObject.QueryTable \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3063\u3066\u3001<br \/>\n\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408<br \/>\n\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d<\/p>\n<pre class=\"lang:default decode:true \">\r\n'\r\n'\r\nSub PowerQueryRefresh_01()\r\n\r\nDim o_Listobj As ListObject\r\n\r\nSet o_Listobj = Worksheets(\"Sheet1\").ListObjects(\"table01\")\r\no_Listobj.QueryTable.BackgroundQuery = False\r\n'\u2191\u3053\u306e\u8a2d\u5b9a\u5fd8\u308c\u308b\u3068\u30d5\u30ea\u30fc\u30ba\u3053\u304f\u304b\u3082\u3002\r\no_Listobj.Refresh\r\n\r\nMsgBox \"\u66f4\u65b0\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\"\r\n\r\nEnd Sub\r\n'\r\n'\r\n<\/pre>\n<p>\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a<\/p>\n<p>\u306a\u304a\u3001<\/p>\n<p>Set o_Listobj = Worksheets(\"Sheet1\").ListObjects(\"table01\")<\/p>\n<p>\u306e<\/p>\n<p>\u300ctable01\u300d<\/p>\n<p>\u306f\u3001\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u30c6\u30fc\u30d6\u30eb\u540d\u3067\u3059\u3002<br \/>\n\u30ea\u30dc\u30f3\u306e\u300c\u30c6\u30fc\u30d6\u30eb\u30c7\u30b6\u30a4\u30f3\u300d\u30bf\u30d6\u3067\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><SPAN>\u3000\u3000<\/SPAN><\/p>\n<p>\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d<br \/>\n\u2605(02)<br \/>\nWorkbookConnection.OLEDBConnection \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3063\u3066\u3001<br \/>\n\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408<br \/>\n\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d<\/p>\n<pre class=\"lang:default decode:true \">\r\n'\r\n'\r\nSub PowerQueryRefresh_02()\r\n\r\nDim o_WorkbookCn As WorkbookConnection\r\n\r\nSet o_WorkbookCn = ActiveWorkbook.Connections(\"Q1\")\r\no_WorkbookCn.OLEDBConnection.BackgroundQuery = False\r\n'\u2191\u3053\u306e\u8a2d\u5b9a\u5fd8\u308c\u308b\u3068\u30d5\u30ea\u30fc\u30ba\u3053\u304f\u304b\u3082\u3002\r\no_WorkbookCn.OLEDBConnection.Refresh\r\n\r\nMsgBox \"\u66f4\u65b0\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\"\r\n\r\nEnd Sub\r\n'\r\n'\r\n<\/pre>\n<p>\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a<\/p>\n<p>ActiveWorkbook.Connections(\"Q1\").OLEDBConnection.BackgroundQuery = False<\/p>\n<p>\u306e<\/p>\n<p>\u300c\"Q1\"\u300d\u306f<\/p>\n<p>\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u3067<br \/>\n\uff1f ActiveWorkbook.Connections(1).Name<br \/>\n\u3068\u304b<br \/>\n\uff1f ActiveWorkbook.Connections(2).Name<br \/>\n\u3067\u51fa\u3066\u304f\u308b\u540d\u524d\u3092\u4f7f\u3048\u3070\u3044\u3044\u3067\u3059\u3002<\/p>\n<p>\u81ea\u5206\u306f\u9006\u306b\u3001\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u3067\u3001<br \/>\nActiveWorkbook.Connections(1).Name = \"Q1\"<br \/>\n\u307f\u305f\u3044\u306b\u3001\u81ea\u5206\u306e\u597d\u304d\u306a\u540d\u524d\u306b\u5f37\u5236\u8a2d\u5b9a\u3057\u3066\u3057\u307e\u3063\u3066\u304b\u3089\u3001<br \/>\n\u305d\u306e\u540d\u524d\u3092\u4f7f\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3072\u3068\u307e\u305a\u4ee5\u4e0a\u3067\u3059\u304c\u3001\u307b\u304b\u306b\u3082\u65b9\u6cd5\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u3010\u30aa\u30de\u30b1\u3011<br \/>\n\u30d6\u30c3\u30af\u5185\u306e\u3059\u3079\u3066\u306e\u63a5\u7d9a\u3092\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u3002\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u304c\u7d42\u308f\u308b\u307e\u3067\u5f85\u3061\u306a\u304c\u3089\u3002<\/p>\n<pre class=\"lang:default decode:true \">\r\n'\r\n'\r\n\r\nSub PowerQueryRefresh_02()\r\n \r\n    Dim o_WorkbookCn As WorkbookConnection\r\n\r\n    \r\n'    Set o_WorkbookCn = ActiveWorkbook.Connections(\"\u30af\u30a8\u30ea - Sheet2org\")\r\n'    o_WorkbookCn.OLEDBConnection.BackgroundQuery = False\r\n'    '\u2191\u3053\u306e\u8a2d\u5b9a\u5fd8\u308c\u308b\u3068\u30d5\u30ea\u30fc\u30ba\u3053\u304f\u304b\u3082\u3002\r\n'    o_WorkbookCn.OLEDBConnection.Refresh\r\n'\r\n'    ActiveSheet.Range(\"A9\") = \"\u66f4\u65b0\u5b8c\u3057\u307e\u3057\u305f\"\r\n'    'MsgBox \"\u66f4\u65b0\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\"\r\n\r\n\r\n    For Each o_WorkbookCn In ActiveWorkbook.Connections\r\n        o_WorkbookCn.OLEDBConnection.BackgroundQuery = False\r\n        o_WorkbookCn.OLEDBConnection.Refresh\r\n        ActiveSheet.Range(\"A9\") = \"\u66f4\u65b0\u5b8c\u3057\u307e\u3057\u305f\"\r\n    Next\r\n'\r\nEnd Sub\r\n'\r\n'\r\n<\/pre>\n<p>\u305d\u306e\u969b\u3001\u305d\u306e\u63a5\u7d9a\u304c\u3069\u306e\u30b7\u30fc\u30c8\u306e\u3069\u306e\u30c6\u30fc\u30d6\u30eb\uff08\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u51fa\u529b\u5148\uff09\u306b\u3042\u308b\u304b\u3082\u540c\u6642\u306b\u8abf\u3079\u306a\u304c\u3089\u3001\u5168\u90e8\u66f4\u65b0\u3059\u308b\u30b3\u30fc\u30c9\uff08ChatGPT\u306b\u805e\u3044\u305f\uff09<\/p>\n<pre class=\"lang:default decode:true \">\r\n'\r\n'\r\nSub PowerQueryRefreshAndWsNmGetAndLObjNmGet01()\r\n\r\n    Dim o_WorkbookCn As WorkbookConnection\r\n    Dim ws As Worksheet\r\n    Dim lo As ListObject\r\n    \r\n    ActiveSheet.Range(\"A9\") = \"\"\r\n    \r\n    For Each o_WorkbookCn In ActiveWorkbook.Connections\r\n        o_WorkbookCn.OLEDBConnection.BackgroundQuery = False\r\n        o_WorkbookCn.OLEDBConnection.Refresh\r\n        \r\n        ' \u5404\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u8d70\u67fb\u3057\u3066\u3001\u8a72\u5f53\u306eListObject\u3092\u63a2\u3059\r\n        For Each ws In ActiveWorkbook.Worksheets\r\n            For Each lo In ws.ListObjects\r\n                If lo.SourceType = xlSrcQuery Then\r\n                    If lo.QueryTable.WorkbookConnection.Name = o_WorkbookCn.Name Then\r\n                        Debug.Print \"\u63a5\u7d9a\u540d:\u300c\" & o_WorkbookCn.Name & \" \u300d\u3068\u3044\u3046\u63a5\u7d9a\u306f\u3001\u30ef\u30fc\u30af\u30b7\u30fc\u30c8: \u300c\" & ws.Name & \" \u300d\u306e\u300e \" & lo.Name & \" \u300f\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u306b\u3042\u308a\u307e\u3059\u3002\"\r\n                    End If\r\n                End If\r\n            Next lo\r\n        Next ws\r\n        \r\n        \r\n    Next o_WorkbookCn\r\n    \r\n    ActiveSheet.Range(\"A9\") = \"\u66f4\u65b0\u5b8c\u4e86\u3057\u307e\u3057\u305f\"\r\n    \r\nEnd Sub\r\n\r\n\u203b\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u51fa\u307e\u3059\u3002\r\n\r\n\u63a5\u7d9a\u540d:\u300c\u30af\u30a8\u30ea - Sheet2org \u300d\u3068\u3044\u3046\u63a5\u7d9a\u306f\u3001\u30ef\u30fc\u30af\u30b7\u30fc\u30c8: \u300cSheet2org \u300d\u306e\u300e Sheet2org \u300f\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u306b\u3042\u308a\u307e\u3059\u3002\r\n\u63a5\u7d9a\u540d:\u300c\u30af\u30a8\u30ea - Sheet2org (2) \u300d\u3068\u3044\u3046\u63a5\u7d9a\u306f\u3001\u30ef\u30fc\u30af\u30b7\u30fc\u30c8: \u300cSheet2org (2) \u300d\u306e\u300e Sheet2org3 \u300f\u30c6\u30fc\u30d6\u30eb\u306e\u4e2d\u306b\u3042\u308a\u307e\u3059\u3002\r\n\r\n\r\n\r\n'\r\n'\r\n<\/pre>\n<p>\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d\uff1d<\/p>\n<p>\u3010\u30aa\u30de\u30b1\uff12\uff1a\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u5834\u5408\u306e\u66f4\u65b0\u5f85\u3061\u3011<\/p>\n<p>\u25cf\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u5834\u5408<br \/>\n\uff08QueryTable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5185\u5305\u3057\u3066\u3044\u308b\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u5834\u5408\u306e\u307f\uff09<\/p>\n<p>\u307e\u305a\u306f\u4ee5\u4e0b\u306e\u5185\u5bb9\u306e\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u300cclsQueryTableEvents\u300d\u3068\u3044\u3046\u540d\u524d\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u30b3\u30fc\u30c9\u4e38\u3054\u3068\u30b3\u30d4\u30da\u3067OK\u3002<\/p>\n<pre class=\"lang:default decode:true \">\r\n'\r\n'\r\n\r\nOption Explicit\r\n\r\n' Class Module: clsQueryTableEvents\r\nPublic WithEvents qt As QueryTable\r\nPublic s_flg01 As String\r\n\r\nPrivate Sub Class_Initialize()\r\n    s_flg01 = \"\"\r\nEnd Sub\r\n\r\nPrivate Sub qt_AfterRefresh(ByVal Success As Boolean)\r\n    s_flg01 = \"\u66f4\u65b0\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\u6210\u529f: \" & Success\r\nEnd Sub\r\n\r\n'\r\n'\r\n<\/pre>\n<p>\u3067\u3001\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u304b\u3089\u306e\u547c\u3073\u51fa\u3057\u4f8b\u3002<br \/>\n\u3053\u308c\u3082\u4e38\u3054\u3068\u30b3\u30d4\u30da\u3067OK\u3067\u3059\u3002<\/p>\n<p>QueryTable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092Refresh\u3059\u308b\u3068\u3001QueryTable\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306eAfterRefresh\u30a4\u30d9\u30f3\u30c8\u304c\u547c\u3073\u51fa\u3055\u308c\u3066\u304b\u3089\u3001\u3064\u307e\u308a\u3001\u300c\u66f4\u65b0\u3092\u5f85\u3063\u3066\u304b\u3089\u300d\u3001\u30bb\u30eb\u306b\u60c5\u5831\u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002<br \/>\nF8\u30ad\u30fc\u5b9f\u884c\u3092\u3059\u308b\u3068\u308f\u304b\u308a\u3084\u3059\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u300cSetupQueryTableEvent02()\u300d\u306e\u307b\u3046\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u72b6\u6cc1\u306b\u5408\u308f\u305b\u3089\u308c\u308b\u306a\u3089\u3001\u300cSetupQueryTableEvent01()\u300d\u3067\u3082\u3044\u3044\u3067\u3059\u3051\u3069\u3002<\/p>\n<pre class=\"lang:default decode:true \">\r\n'\r\n'\r\nOption Explicit\r\n\r\nDim qtEvents As clsQueryTableEvents\r\n\r\n\r\nSub SetupQueryTableEvent02()\r\n    \r\n    Dim o_ItemLstObj01 As ListObject\r\n            \r\n    For Each o_ItemLstObj01 In ActiveSheet.ListObjects\r\n    \r\n        Range(\"A9\") = \"\"\r\n        \r\n        Set qtEvents = New clsQueryTableEvents\r\n        Set qtEvents.qt = o_ItemLstObj01.QueryTable\r\n        qtEvents.qt.BackgroundQuery = False 'False\u3092\u6307\u5b9a \u3059\u308b\u3068\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u30af\u30a8\u30ea\u3092\u5b9f\u884c\u3055\u305b\u306a\u3044\u3002\uff1d\u5f85\u3064\u3002\uff08True \u3092\u6307\u5b9a \u3059\u308b\u3068\u3001\u30af\u30a8\u30ea \u30c6\u30fc\u30d6\u30eb\u306e\u30af\u30a8\u30ea\u304c\u975e\u540c\u671f\u7684\u306b (\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067) \u5b9f\u884c\u3055\u308c\u307e\u3059\u3002 \u8aad\u307f\u53d6\u308a\/\u66f8\u304d\u8fbc\u307f\u304c\u53ef\u80fd\u306a Boolean \u3067\u3059\u3002https:\/\/learn.microsoft.com\/ja-jp\/office\/vba\/api\/excel.querytable.backgroundquery\uff09\r\n        qtEvents.qt.Refresh\r\n        \r\n        If qtEvents.s_flg01 <> \"\" Then\r\n            Range(\"A9\") = qtEvents.s_flg01\r\n        Else\r\n        \r\n        End If\r\n        \r\n    Next\r\n    \r\nEnd Sub\r\n\r\n\r\n\r\nSub SetupQueryTableEvent01()\r\n   \r\n    Range(\"A9\") = \"\"\r\n    \r\n    Set qtEvents = New clsQueryTableEvents\r\n    Set qtEvents.qt = ActiveSheet.ListObjects(1).QueryTable\r\n    qtEvents.qt.Refresh\r\n    \r\n    If qtEvents.s_flg01 <> \"\" Then\r\n        Range(\"A9\") = qtEvents.s_flg01\r\n    Else\r\n    \r\n    End If\r\n    \r\nEnd Sub\r\n\r\n\r\n'\r\n'\r\n<\/pre>\n<p><SPAN>\u3000\u3000<\/SPAN><\/p>\n<p>\u2605(03)\u8907\u6570\u3073\u30af\u30a8\u30ea\u3092\u5168\u3066\u66f4\u65b0<\/p>\n<p>ActiveWorkbook.RefreshAll<\/p>\n<p>\u3060\u3051\u3067\u884c\u3051\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u306e\u969b\u3001\u3082\u3057\u3001\u3046\u307e\u304f\u3044\u304b\u306a\u304b\u3063\u305f\u3089\u3001<br \/>\n\u3059\u3079\u3066\u306e\u30d1\u30ef\u30fc\u30af\u30a8\u30ea\u306e\u7d50\u679c\u306e\u8868\u306e<br \/>\n\u300c\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u66f4\u65b0\u3059\u308b\u300d\u306e\u30c1\u30a7\u30c3\u30af\u3092\u306f\u305a\u3059\u3068<br \/>\n\u3044\u3044\u304b\u3082\uff1f\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30bf\u30d6<br \/>\n\u2192\u300c\u30af\u30a8\u30ea\u3068\u63a5\u7d9a\u300d\u306e\u300c\u3059\u3079\u3066\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u306e\u300c\u25bc\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3059<br \/>\n\u2192\u300c\u63a5\u7d9a\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u300d<br \/>\n\u2192\u300c\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u66f4\u65b0\u3059\u308b\u300d\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5916\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3068\u306f\u5192\u982d\u306b\u66f8\u3044\u305f\u3001<br \/>\n\u300c\u00d7\u00d7\u00d7.BackgroundQuery = False\u300d<br \/>\n\u3068\u540c\u3058\u610f\u5473\u3067\u3059\u3002<\/p>\n<p>True\u306b\u3059\u308b\u3068\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9 (\u975e\u540c\u671f\uff1d\u8907\u6570\u306e\u30af\u30a8\u30ea\u306e\u5834\u5408\u306f\u540c\u6642\u4e26\u884c\u51e6\u7406) \u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>False\u306f\u8907\u6570\u306e\u30af\u30a8\u30ea\u306e\u5834\u5408\u3067\u3082\u3001\uff11\u3064\uff11\u3064\u3001\u9806\u756a\u306b\u3084\u308a\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u30012007\u306e\u30d8\u30eb\u30d7\u3088\u308a\u3002<\/p>\n<p>QueryTable.BackgroundQuery \u30d7\u30ed\u30d1\u30c6\u30a3<br \/>\n\u3059\u3079\u3066\u8868\u793a<br \/>\n\u3059\u3079\u3066\u975e\u8868\u793a<br \/>\nTrue \u306e\u5834\u5408\u3001\u30af\u30a8\u30ea \u30c6\u30fc\u30d6\u30eb\u306e\u30af\u30a8\u30ea\u3092\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9 (\u975e\u540c\u671f) \u3067\u5b9f\u884c\u3057\u307e\u3059\u3002\u5024\u306e\u53d6\u5f97\u304a\u3088\u3073\u8a2d\u5b9a\u304c\u53ef\u80fd\u3067\u3059\u3002\u30d6\u30fc\u30eb\u578b (Boolean) \u306e\u5024\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>OLEDBConnection.BackgroundQuery \u30d7\u30ed\u30d1\u30c6\u30a3<br \/>\nTrue \u306e\u5834\u5408\u3001 OLE DB \u63a5\u7d9a\u306e\u30af\u30a8\u30ea\u3092\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9 (\u975e\u540c\u671f) \u3067\u5b9f\u884c\u3057\u307e\u3059\u3002\u5024\u306e\u53d6\u5f97\u304a\u3088\u3073\u8a2d\u5b9a\u304c\u53ef\u80fd\u3067\u3059\u3002\u30d6\u30fc\u30eb\u578b (Boolean) \u306e\u5024\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>QueryTable .Refreshing \u30d7\u30ed\u30d1\u30c6\u30a3<br \/>\n\u6307\u5b9a\u3055\u308c\u305f\u30af\u30a8\u30ea \u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3059\u308b\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9 \u30af\u30a8\u30ea\u304c\u5b9f\u884c\u4e2d\u3067\u3042\u308b\u5834\u5408\u3001\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024\u306f True \u3067\u3059\u3002\u5024\u306e\u53d6\u5f97\u304a\u3088\u3073\u8a2d\u5b9a\u304c\u53ef\u80fd\u3067\u3059\u3002\u30d6\u30fc\u30eb\u578b (Boolean) \u306e\u5024\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 <\/p>\n<p>OLEDBConnection.Refreshing \u30d7\u30ed\u30d1\u30c6\u30a3<br \/>\n\u6307\u5b9a\u3055\u308c\u305f OLE DB \u63a5\u7d9a\u306b\u5bfe\u3059\u308b\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9 OLE DB \u30af\u30a8\u30ea\u304c\u5b9f\u884c\u4e2d\u3067\u3042\u308b\u5834\u5408\u3001\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024\u306f True \u3067\u3059\u3002\u5024\u306e\u53d6\u5f97\u304a\u3088\u3073\u8a2d\u5b9a\u304c\u53ef\u80fd\u3067\u3059\u3002\u30d6\u30fc\u30eb\u578b (Boolean) \u306e\u5024\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p><SPAN>\u3000\u3000<\/SPAN><\/p>\n<p>\u53c2\u8003URL<br \/>\n\u300cCode VBA\u300d<br \/>\n<a href=\"https:\/\/www.codevba.com\/Excel\/WorkbookConnection.htm#.ZA1eK3bP1nJ\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.codevba.com\/Excel\/WorkbookConnection.htm#.ZA1eK3bP1nJ<\/a><\/p>\n<p><SPAN>\u3000\u3000<\/SPAN><br \/>\n<SPAN>\u3000\u3000<\/SPAN><br \/>\n<SPAN>\u3000\u3000<\/SPAN><br \/>\n<SPAN>\u3000\u3000<\/SPAN><\/p>\n","protected":false},"excerpt":{"rendered":"\u2605ExcelVBA \uff5e \u30d1\u30ef\u30fc\u30af\u30a8\u30ea\uff08PowerQuery\uff09\u306e\u66f4\u65b0\u65b9\u6cd5\u3044\u308d\u3044\u308d \u3000\u3000 \u203b\u307e\u3060\u66f8\u304d\u304b\u3051\u3067\u3059\u3002\u3059\u307f\u307e\u305b\u3093\u3002 \u203b\u9593\u9055\u3063\u3066\u305f\u3089\u3059\u307f\u307e\u305b\u3093\u3002 \u203b\u30e1\u30e2\u66f8\u304d\u306a\u306e\u3067\u3001\u81ea\u5206\u3067\u3082\u610f\u5473\u4e0d\u660e\u306a\u7b87\u6240\u3082\u591a\u3044\u3067\u3059\u3002\u3054\u3081\u3093\u306a\u3055\u3044\u3002 \u3000\u3000 ...","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[234],"_links":{"self":[{"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/posts\/1886"}],"collection":[{"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/comments?post=1886"}],"version-history":[{"count":0,"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/posts\/1886\/revisions"}],"wp:attachment":[{"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/media?parent=1886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/euc-access-excel-db.com\/tips\/wp-json\/wp\/v2\/categories?post=1886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}