https://excel-ubara.com/excelvba4/EXCEL232.html
https://k-sugi.sakura.ne.jp/it_synthesis/windows/vb/2127/
-- 1. 開発タブの挿入でボタンを作成
※ActiveXコントロールのものを使用する
-- 2. デザインモードONで作成したボタンをダブルクリックするとエディタが開くので下記コードを記載。デザインモードOFFで実行
※ 下記設定必要
「Microsoft VBScript Regular Expressions 5.5」の参照設定
Option Explicit
Private Sub CommandButton1_Click()
'画面を更新しない
Application.ScreenUpdating = False
'確認メッセージを表示しない
Application.DisplayAlerts = False
Dim re As New RegExp
'テスト用ファイル作成
Open ThisWorkbook.Path & "\a.txt" For Output As #1
Print #1, "# REQUIRES-PROPERTIES-FILE - # Do not remove this comment! =>"
Print #1, "# =>"
Print #1, " DATABASEURI = '${databases.db01.folder.01ds.datasources.jdbc.ds01.DATABASEURI}' =>"
Print #1, " USERNAME = '${databases.db01.folder.01ds.datasources.jdbc.ds01.USERNAME}' =>"
Print #1, " USERPASSWORD = '${databases.db01.folder.01ds.datasources.jdbc.ds01.USERPASSWORD}' ${databases.db01.folder.01ds.datasources.jdbc.ds01.USERPASSWORD.ENCRYPTED} =>"
Print #1, " CATALOGNAME='${databases.db01.folder.02bv.views.jdbc.b_tab1.CATALOGNAME}' =>"
Print #1, " DATABASEURI = 'jdbc:mysql://localhost:3306/test' <="
Print #1, " USERNAME = 'root' <="
Print #1, " USERPASSWORD = 'xxxx' ENCRYPTED <="
Print #1, " CATALOGNAME='test' <="
Print #1, "***** 3.TXT"
Print #1, " 47: DRIVERCLASSNAME = 'com.mysql.jdbc.Driver'"
Print #1, " 48: DATABASEURI = '${databases.db01.folder.01ds.datasources.jdbc.ds01.DATABASEURI}'"
Print #1, " 49: USERNAME = '${databases.db01.folder.01ds.datasources.jdbc.ds01.USERNAME}'"
Print #1, " 50: USERPASSWORD = '${databases.db01.folder.01ds.datasources.jdbc.ds01.USERPASSWORD}' ${databases.db01.folder.01ds.datasources."
Print #1, " 51: jdbc.ds01.USERPASSWORD.ENCRYPTED}"
Print #1, " 52: CLASSPATH = 'mysql-5'"
Print #1, "*****"
Close #1
Dim buf As String
Dim mc As MatchCollection
Dim m As Match
With re
.Global = True
.IgnoreCase = False
.Pattern = "\${.*?}"
Open ActiveWorkbook.Path & "\a.txt" For Input As #1
Do Until EOF(1)
Line Input #1, buf
' Debug.Print (buf)
If .test(buf) Then
' Debug.Print ("found")
Set mc = re.Execute(buf)
For Each m In mc
Debug.Print m
Next m
End If
Loop
Close #1
End With
MsgBox ("処理完了")
'確認メッセージを表示する
Application.DisplayAlerts = True
'画面を更新する
Application.ScreenUpdating = True
End Sub