[解決] "Sheet1.A1:B5" からセルオブジェクト

スプレッドシート (Calc) について
返信する
K.Tsunoda
記事: 71
登録日時: 11月 2, 2008, 6:44 pm
連絡する:

[解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by K.Tsunoda »

こんにちは。

"Sheet1.A1:B5" といったセル範囲の文字列からセルオブジェクトを一発で設定する簡単な方法はありますか?

Excel/VBA の場合は Evaluate メソッドで一発変換できます。

コード: 全て選択

Dim MyRng As Range
Set MyRng = Nothing
On Error Resume Next
Set MyRng = Application.Evaluate("Sheet1!A1:B5")
On Error GoTo 0
If (MyRng Is Nothing) Then
  MsgBox "Range Error"
End if
とりあえず、今は、シートとセルを分離して、こんな風にしてみましたが、
VBA のように一発でできる方法は無いでしょうか?

コード: 全て選択

Public Function RefEditRange2Object(ByVal argRangeString As String) As Object
' RangeString's pattern is "Sheet1.A1:B5"(The $ mark is already removed.)
' When Cell-Range-String is not right, [Nothing] returns.

Dim oSheets As Object
Dim oSheet As Object
Dim oRange As Object
Dim vntRangeString As Variant

  vntRangeString = Split(argRangeString, ".")   
  if (UBound(vntRangeString) <> 1) Then
    RefEditRange2Object = Nothing
  Else
    If (vntRangeString(0) = "") or (vntRangeString(1) = "") Then
      RefEditRange2Object = Nothing
    Else
      oSheets = ThisComponent.getSheets()
      If oSheets.hasByName(vntRangeString(0)) Then
        oSheet = oSheets.getByName(vntRangeString(0))
        On Error Resume Next
        oRange = Nothing
        oRange = oSheet.getCellRangeByName(vntRangeString(1))
        On Error Goto 0
        If (oRange is Nothing) Then
          RefEditRange2Object = Nothing
        Else
          RefEditRange2Object = oRange  'OK
        End If
      Else
        RefEditRange2Object = Nothing  
      End If
    End If
  End If
End Function
最後に編集したユーザー K.Tsunoda [ 6月 19, 2009, 11:47 am ], 累計 1 回
tani
記事: 60
登録日時: 6月 13, 2008, 10:12 am

Re: "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by tani »

とりあえず、今は、シートとセルを分離して、こんな風にしてみましたが、
VBA のように一発でできる方法は無いでしょうか?
とりあえずここでやられておられる例が一番良いやり方のように思えます。
一応以下のようなコードだと「Sheet1.A1:B5」という文字列をそのまま使用したいという要件は満たしているように思いますが、シンプルには程遠いですね。

コード: 全て選択

sub Main
  dim oFrame as object, oRange as object
  dim dispatcher as object

  oFrame = ThisComponent.getCurrentController().getFrame()
  dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

  dim args1(0) as new com.sun.star.beans.PropertyValue
  args1(0).Name = "ToPoint"
  args1(0).Value = "Sheet1.A1:B5"

  dispatcher.executeDispatch(oFrame, ".uno:GoToCell", "", 0, args1())

  oRange = ThisComponent.getCurrentController().getSelection()
  Msgbox oRange.AbsoluteName
end sub
K.Tsunoda
記事: 71
登録日時: 11月 2, 2008, 6:44 pm
連絡する:

Re: "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by K.Tsunoda »

こんにちは。
>「Sheet1.A1:B5」という文字列をそのまま使用したいという要件は満たしているように思いますが、シンプルには程遠いですね。
そうですね。
これを使い易いようにユーザー関数にと思うと、逆に、敢えて、この方法に拘る必要性が無くなってしまいますしね。
Split のユーザー関数で対応することにします。

> AbsoluteName
これは知らなかったです(謝々)
Prind1980
記事: 1
登録日時: 12月 23, 2024, 7:50 pm

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Prind1980 »

space waves is a fascinating journey of space exploration.
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Our variable dc power supplies include: programmable power supply, bench power supply, high voltage power supply, and high precision power supply. You can choose the appropriate dc power supply based on your specific requirements from our product range.
https://variabledcpowersupply.com
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Wire EDM Machine Manufacturer
High cutting precision, ideal for machining complex parts
Smooth operation, easy to operate, and built to last.
Trustworthy quality, fast cutting, excellent productivity.
Widely used in the processing of various dies.
Support wholesale, custom, OEM & ODM services.
https://wireedmmachines.com
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Experience Crazy Cattle 3D
Crazy Cattle 3D offers an exhilarating battle royale experience unlike any other. As a sheep with explosive capabilities, your mission is to outmaneuver and outlast other ovine competitors in this chaotic survival game.

Developed by an independent creator with a passion for unique gameplay, Crazy Cattle 3D combines humor with challenging mechanics. Players navigate through three distinct environments—Ireland, Iceland, and New Zealand—each presenting unique terrain challenges that affect your sheep's movement and strategy.
https://crazycattle3d.com
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Welcome to Cheese Chompers 3D
Cheese Chompers 3D is a hilarious fast-paced knockout game where you control wobbly rats in chaotic battles across a vibrant arena. Experience the thrill of pushing your opponents off the platform while trying to maintain your balance. With simple controls and physics-based gameplay, it's easy to learn but challenging to master. Play for free directly in your browser, no downloads required!
https://cheesechompers3d.cc/
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Block Blast
is a fast-paced puzzle game where players match colored blocks to clear the board. Use mouse/arrow keys to move and spacebar to rotate. Clear blocks quickly to score as high as possible before time runs out!
https://blockblast.pro
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Planet Clicker is a resource-generating idle game where you click planets to earn and upgrade production. Start with Earth, unlock others, and automate growth. Control is simple: just click to grow your galaxy!
https://theplanetclicker.com/
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

¿Qué es el APK de la aplicación Telegram?
Telegram es una potente plataforma de mensajería basada en la nube diseñada para la comunicación moderna. A diferencia de otras aplicaciones, Telegram se centra en la privacidad y la velocidad con funciones como Chats Secretos y sincronización entre dispositivos. Ya sea para hablar con tus amigos, ser parte de grupos públicos o seguir canales de Telegram, puedes contar con una experiencia de mensajería segura y sin complicaciones.

La versión que ofrecemos aquí es diferente a la de Google Play Store. Estamos proporcionando un APK de Telegram para usuarios que tienen limitaciones con sus cuentas de Google o restricciones de red, y lo más importante, para aquellos que desean tener las funciones premium sin suscripción.
https://tgramapp.download
OpenOffice 3.1
Alistair66
記事: 8
登録日時: 4月 30, 2025, 3:17 pm
連絡する:

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by Alistair66 »

Tik Tok (Douyin Overseas Edition)-¡El centro de creación de vídeos cortos al que acuden 2.500 millones de usuarios de todo el mundo! Aquí, puede publicar una enseñanza de baile, un párrafo divertido o un vídeo de desafío popular en 15 segundos, y el algoritmo inteligente empuja con precisión los puntos calientes de moda que le interesan; la función de colaboración de una sola tecla vincula a creadores extranjeros, y el área de comentarios se convierte en un campo social transnacional en un segundo; y la sala de transmisión en vivo pasa a través de las golosinas transfronterizas, ¡y puede desbloquear una nueva experiencia de consumo mientras ve y compra! Tik Tok, como homólogo global de Douyin, continúa el marco interactivo central de su producto matriz y remodela la escena del entretenimiento y el consumo con el modo de "contenido breve + fuerte interacción", convirtiéndose en un espacio digital inmersivo con creación, socialización y valor comercial. Cientos de millones de usuarios conectan el mundo con sus lentes cada día, ¿a qué esperas? ¡Haz clic para descargar Tik Tok APK y captura tus momentos más destacados con vídeos cortos!
https://tkapk.download
OpenOffice 3.1
MaeDavila
記事: 5
登録日時: 11月 14, 2024, 8:19 pm

Re: [解決] "Sheet1.A1:B5" からセルオブジェクト

投稿記事 by MaeDavila »

I look forward to engaging with this information immediately, as it promises to provide a deep dive into the subject that will be both informative and thought-provoking.
http://italianbrainrot-games.com/
Windows 10, Apache OpenOffice 4.1.14
返信する

“Calc”に戻る