ページ 11

【VBScript】VBSでCalc内の文字列を置換したい

Posted: 5月 24, 2021, 3:38 pm
by 三ツ星みかん
皆様 お世話になります。

openoffice 4.1.5
windows10
で開発をしております。

VBscriptからcalc内の文字列を置換したいのですが、
SheetオブジェクトからcreateReplaceDiscriptor()の呼び出し時に
「オブジェクトでサポートされていないプロパティまたはメソッドです。」
とエラーが発生します。

ソースコードは下記です。
calcを起動し、特定のセルに「テスト」と文字を格納することは出来ているので、
sheetのオブジェクトは正常に取得出来ていると思うのですが、
先にも書いた通り「ReplaceDiscriptor」の取得が出来ません。

下記の記事が似た事象なのですが原因が違いそうです。
https://forum.openoffice.org/en/forum/v ... 12#p331147

分かる方がいましたらご教授いただければ幸いです。

コード: 全て選択

' param : tgtCalcFile → calcファイルパス
function replaceCalc(tgtCalcFile)

    Dim OSM, oDesktop, dummyArray
    Set OSM = CreateObject("com.sun.star.ServiceManager")
    Set oDesktop = OSM.createInstance("com.sun.star.frame.Desktop")

    Dim Result() 'As Object
    dummyArray = Result

    Dim oCalcDoc, oSheet, oSerch
    Set oCalcDoc = oDesktop.loadComponentFromURL("file:///"&tgtCalcFile,"_blank", 0, dummyArray)
    Set oSheet = oCalcDoc.getSheets().getByIndex(0)

	'デバッグ用:対象のシートに「テスト」と表示される。
    oSheet.getCellByPosition(1,1).String = "テスト"

    oSerch = oSheet.createReplaceDescriptor() 'ここが動かない。
    oSerch.SearchString = "%置換前文字列%"
    oSerch.ReplaceString = "置換後文字列"

    oSheet.replaceAll(oSerch)

    Set OSM = Nothing

end function

Re: 【VBScript】VBSでCalc内の文字列を置換したい

Posted: 11月 19, 2024, 12:12 pm
by hebemiley
Sprunked is a fantastic platform for musical exploration! The community is so supportive, and I love sharing my compositions with others. The intuitive interface allows me to create unique rhythms easily. It’s a wonderful way to connect with fellow music enthusiasts and collaborate on projects!

Re: 【VBScript】VBSでCalc内の文字列を置換したい

Posted: 4月 26, 2025, 10:49 am
by braingattsss
If you're into custom avatars or playful digital art, you should definitely check out Action Figure Ai Generator. It's a fun tool that transforms your photo into a toy-style 3D character, complete with packaging and accessories.