Last active
November 10, 2021 14:33
-
-
Save pandanote-info/2bc9f6c607bbafa5a0b7878e320b093e to your computer and use it in GitHub Desktop.
ExcelのシートからSQLite3のCREATE TABLE句が記述されたファイルを生成するためのExcelのアドインのThisWorkbookに記述するコード。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public WithEvents CreateTableStatementForSQLite3 As Application | |
Private Sub Workbook_Open() | |
Set CreateTableStatementForSQLite3 = Application | |
End Sub | |
Private Sub Workbook_BeforeClose(Cancel As Boolean) | |
Set CreateTableStatementForSQLite3 = Nothing | |
End Sub | |
Private Sub DeleteControls() | |
On Error Resume Next | |
Application.CommandBars("Row").Controls("Create文を作る").Delete | |
Application.CommandBars("Cell").Controls("選択したセルからCreate文を作る").Delete | |
On Error GoTo 0 | |
End Sub | |
Private Sub Workbook_AddinUninstall() | |
DeleteControls | |
End Sub | |
Private Sub CreateTableStatementForSQLite3_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) | |
DeleteControls | |
With Application.CommandBars("Row").Controls.Add(Before:=1) | |
.Caption = "Create文を作る" | |
.OnAction = "Create_CreateClause" | |
End With | |
If Target.Rows.Count = 1 Or Target.Columns.Count = 1 Then | |
With Application.CommandBars("Cell").Controls.Add(Before:=1) | |
.Caption = "選択したセルからCreate文を作る" | |
.OnAction = "Create_CreateClauseFromCells" | |
End With | |
End If | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment