Calcで開いているファイルをリストボックスに表示、選択し前面に表示する実験 [LibreOffice Calc Basic]
Calcで開いていファイルをリストボックスに表示、選択し前面に表示する実験
実験中につき、不具合が発生するが修正して完成する予定
参考サイト ttp://blog.livedoor.jp/addinbox/archives/51192547.html
ttps://forum.openoffice.org/ja/forum/viewtopic.php?f=10&t=409
Calc操作では下図のようなことをマクロでする
実行イメージ
ダイアログを作成
Public oDialog as object
Sub ShowDiarog
dim oSheets as object
'ダイアログ(Excelフォーム)初期設定
DialogLibraries.LoadLibrary("Standard")
oDialog=CreateUnoDialog(DialogLibraries.Standard.Dialog1)
oDialog.Title="開いているBook一覧"
'リストボックスに開いているBOOKを表示
For Each oComponent In StarDesktop.Components
If HasUnoInterfaces(oComponent, "com.sun.star.frame.XModel") Then
oDialog.getControl("ListBox1").AddItem(oComponent.Title,i)
'oDialog.getControl("ListBox1").AddItem(oComponent.URL,i) '文字化け
i=i+1
End If
Next
'ダイアログ表示
oDialog.Execute()
oDialog.Dispose()
End Sub
Sub CloseDialog
'ダイアログを閉じる
oDialog.endExecute()
End Sub
Sub SelectWorkbook
'リストボックスに表示されたファイルを前面にする
'GetComponent ユーザー定義関数を使用
'参考サイト ttp://blog.livedoor.jp/addinbox/archives/51192547.html
'2014/05/14
Dim sUrl As String
Dim oFrame As Object
Dim dUrl As String
Dim oComponent As Object
'リストボックスで選択されたファイル名
sUrl = oDialog.getControl("ListBox1").getSelectedItem()
'msgbox sUrl
'選択されたファイルを前面に表示
If Not (sUrl = "") Then
dUrl="/home/telstar/ドキュメント/LibreOffice/Calc/" 'パス 指定以外ではNG
oComponent = GetComponent(dUrl & sUrl) 'GetComponent ユーザー定義関数
oFrame = oComponent.CurrentController.Frame
oFrame.getContainerWindow().toFront()
End If
oDialog.endExecute() '自動的に閉じる
End Sub
Function getComponent(f as String) as Component
'ユーザー定義関数
'ufl はフルパス
url = ConvertToUrl(f)
oComps = StarDesktop.Components
oCompsEnum = oComps.createEnumeration()
while oCompsEnum.hasMoreElements()
oComp = oCompsEnum.nextElement()
if HasUnoInterfaces(oComp, "com.sun.star.frame.XModel") then
if (url = oComp.getURL()) then
getComponent = oComp
Exit Function
endif
endif
wend
getComponent = StarDesktop.CurrentComponent
End Function
Priligy Precio En Farmacia [url=https://cheapcialisll.com/]cialis online ordering[/url] Keflex Prescribing Informationm <a href=https://cheapcialisll.com/#>Cialis</a> Lipitor Cephalexin
by SWADWAY (2020-06-20 06:53)