| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Excel VBA」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
147行目: 147行目:
 
*[[Perl VBのプロパティプロシージャを生成]]  
 
*[[Perl VBのプロパティプロシージャを生成]]  
 
*[[Excel VBA 最初の空白でないセルを返す]]
 
*[[Excel VBA 最初の空白でないセルを返す]]
===ライブラリ===
+
==ライブラリ==
 
+
===Web API (JSON)の取得===
 
====[https://github.com/VBA-tools/VBA-JSON VBA-JSON]====
 
====[https://github.com/VBA-tools/VBA-JSON VBA-JSON]====
----
 
 
*[https://github.com/VBA-tools/VBA-JSON VBA-JSON]
 
*[https://github.com/VBA-tools/VBA-JSON VBA-JSON]
 
 
====[https://github.com/VBA-tools/VBA-Web VBA-WEB]====
 
====[https://github.com/VBA-tools/VBA-Web VBA-WEB]====
----
 
 
*[https://github.com/VBA-tools/VBA-Web VBA-WEB]
 
*[https://github.com/VBA-tools/VBA-Web VBA-WEB]
 
 
====[https://github.com/VBA-tools/VBA-Dictionary/releases VBA-DICTIONARY]====
 
====[https://github.com/VBA-tools/VBA-Dictionary/releases VBA-DICTIONARY]====
----
 
 
*[https://github.com/VBA-tools/VBA-Dictionary/releases VBA-DICTIONARY]
 
*[https://github.com/VBA-tools/VBA-Dictionary/releases VBA-DICTIONARY]
 +
<pre>
 +
Sub JsonTest()
 +
    Dim url As String
 +
    Dim wbClient As New WebClient
 +
   
 +
    url = "https://xxxxxxxxxx"
 +
 +
    Dim Response As WebResponse
 +
    Set Response = wbClient.GetJson(url)
 +
   
 +
    Dim jsonText As String
 +
    jsonText = Response.Content
 +
    Debug.Print jsonText
 +
   
 +
    Dim Json As Object
 +
    Set Json = JsonConverter.ParseJson(jsonText)
 +
   
 +
    Debug.Print JsonConverter.ConvertToJson(Json)
 +
    Debug.Print JsonConverter.ConvertToJson(Json, Whitespace:=2)
 +
   
 +
    Debug.Print Json("_fieldsProto")("imageURL")("stringValue")
 +
 +
End Sub
 +
</pre>
  
 
====部品====
 
====部品====

2021年11月14日 (日) 02:06時点における版

| Excel |

Excel VBA

Tips

Excel操作

セルからテキストを取得

セルからテキストを取得

最終更新日を取得

最終更新日を取得

シートを設定ファイルとして利用する

シートを設定ファイルとして利用する

ユーザフォームを閉じさせない

ユーザフォームを閉じさせない

確認のダイアログを表示させない

確認のダイアログを表示させない

最後のセルを取得

最後のセルを取得

オートフィルタをシート間で同期

オートフィルタをシート間で同期

オートフィルタをで行が隠れているか判定

オートフィルタをで行が隠れているか判定

シート名を指定してハイパーリンクを作成

シート名を指定してハイパーリンクを作成

すべてのシートに対して一括置換

すべてのシートに対して一括置換

処理中一時的に自動計算をとめる

処理中一時的に自動計算をとめる

選択された範囲を処理==
    If TypeName(Selection) = "Range" Then
        For Each c In Selection.Cells
            Debug.Print c.Value
        Next
    End If

文字列操作

数値操作

ステートメント

ファイル操作


ディレクトリの存在チェック
If Dir(pathName, vbDirectory) = "" Then
   :
End If

オブジェクト操作

起動メニューアイコンを表示
Private Const MY_APP_FILE_MK         As String = "ツールバー名"            'ツールバー名
Private Const BTN_MY_APP_FILE_MK     As String = "ボタン名"  'ボタン名
'
'ToolBarをセット
'
Private Sub loadToolBar()
   Dim cbrGatherImgs   As CommandBar
   Dim btnGetImages    As CommandBarButton
   On Error Resume Next
   ' コマンド バーが既に存在するかどうかを確認します。
   ' Set cbrGatherImgs = CommandBars(MY_APP_FILE_MK)
   ' コマンド バーが存在しない場合は作成します。
   If cbrGatherImgs Is Nothing Then
      Err.clear
      Set cbrGatherImgs = CommandBars.add(MY_APP_FILE_MK)
      ' コマンド バーを表示します。
      cbrGatherImgs.Visible = True
      ' ボタン コントロールを追加します。
      Set btnGetImages = cbrGatherImgs.Controls.add
      
      With btnGetImages
         .Style = msoButtonIconAndCaption
         .Caption = BTN_MY_APP_FILE_MK
         .Tag = BTN_MY_APP_FILE_MK
         ' ボタンがクリックされたときに実行するプロシージャを指定します。
         .OnAction = "mayAppMain"
         .FaceId = 270&
      End With
   Else
      ' 既存のコマンド バーを表示します。
      cbrGatherImgs.Visible = True
   End If
End Sub
'
'ToolBarを削除
'
Private Sub unloadToolBar()
  'On Error Resume Next
  On Error GoTo errHandler
  
   ' 存在するコマンド バーを削除します。
   CommandBars(MY_APP_FILE_MK).Delete
    
    Exit Sub
errHandler:
    'NOP
End Sub

'
'ファイルを開いたときに実行
'
Public Sub Auto_Open()
    Call loadToolBar
End Sub
'
'ファイルを閉じたときに実行
'
Public Sub Auto_Close()
    Call unloadToolBar
End Sub

マクロサンプル

ライブラリ

Web API (JSON)の取得

VBA-JSON

VBA-WEB

VBA-DICTIONARY

Sub JsonTest()
    Dim url As String
    Dim wbClient As New WebClient
    
    url = "https://xxxxxxxxxx"

    Dim Response As WebResponse
    Set Response = wbClient.GetJson(url)
    
    Dim jsonText As String
    jsonText = Response.Content
    Debug.Print jsonText
    
    Dim Json As Object
    Set Json = JsonConverter.ParseJson(jsonText)
    
    Debug.Print JsonConverter.ConvertToJson(Json)
    Debug.Print JsonConverter.ConvertToJson(Json, Whitespace:=2)
    
    Debug.Print Json("_fieldsProto")("imageURL")("stringValue")

End Sub

部品

その他