<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Excel/Calc funzione tramite macro]]></title><description><![CDATA[<p dir="auto">Ciao a tutti volevo chiedervi se è possibile ad esempio registrare una funzione tramite il registratore di macro, collegare la macro ad un pulsante che alla pressione esegue la funzione.<br />
Nel dettaglio, io ad esempio vorrei creare un pulsante che esegue la funzione =adesso() e mi stampa data ed ora corrente nella cella in cui sono.<br />
Mi è venuto in mente di provare a registrare la macro mentre premo i pulsanti ed eseguo la funzione ma già eseguendo la macro dalla console vba mi da errore:<br />
Errore di sintassi BASIC, era previsto un simbolo.<br />
Il codice che crea è questo:</p>
<pre><code>REM  *****  BASIC  *****

Private Sub

End Sub


sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = "="

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$P$15"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())


end sub


sub Adesso
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = "=adesso()"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())


end sub


sub data_odierna
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = "=adesso()"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())
</code></pre>
<p dir="auto">Grazie a tutti nel caso, ciao!</p>
]]></description><link>https://dev.connect.gt/topic/202498/excel-calc-funzione-tramite-macro</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 05:27:12 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/202498.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 May 2014 21:29:07 GMT</pubDate><ttl>60</ttl></channel></rss>