OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Macro Recorded Does not work

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
mcanedo
General User
General User


Joined: 12 Jan 2005
Posts: 6

PostPosted: Wed May 11, 2005 3:33 pm    Post subject: Macro Recorded Does not work Reply with quote

Hi:
They way I learned Excel macro programing, was mainly recording macros, and then edting them.

I'm trying to do the same with openoffice, and I record a macro, but when I try to execute it does not work.....

Any Idea what can be wrong?
Regards, Miguel

Here is the code generated by openoffice:

Code:

sub pdfpaya
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(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///home/mcanedo/Documents/2005/tmp/Estados/Estado_de_Cuenta.pdf"
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
args1(4).Name = "FilterData"
args1(4).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageRange",0,"15",com.sun.star.beans.PropertyState.DIRECT_VALUE))
args1(5).Name = "SelectionOnly"
args1(5).Value = true

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


end sub

_________________
Search Free Online Movies at http://www.movinex.com


Last edited by mcanedo on Tue Sep 16, 2008 10:20 am; edited 1 time in total
Back to top
View user's profile Send private message
9point9
Moderator
Moderator


Joined: 31 Aug 2004
Posts: 3875
Location: UK

PostPosted: Wed May 11, 2005 11:39 pm    Post subject: Reply with quote

Maybe because the file already exists. If you try doing a PDF export like that from a macro, it'll work the first time when no file exists and then won't work afterwards because of the existence of a file.
_________________
Arch Linux
OOo 3.2.0

OOoSVN, change control for OOo documents:
http://sourceforge.net/projects/ooosvn/
Back to top
View user's profile Send private message Visit poster's website
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Thu May 12, 2005 1:26 am    Post subject: Reply with quote

Quote:
The way I learned Excel macro programing, was mainly recording macros, and then edting them.

Unfortunately, the macro recorder will not teach you how to write macros in OpenOffice.org.
The macro recorder is only a handy tool for quick and dirty macros. If it works, fine.
For real programming you will have to spend time and read documents like StarOffice 7 Programmer's Guide and others, see http://api.openoffice.org/TipsAndTricks/external.html and of course search and read threads in this forum.

As for you macro, it does not work because you changed the argument list more or less at random. The declaration of args1 does not fit its use. And args(2) and args(3) are not filled.
_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group