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

SOLVED my first subbroutine

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


Joined: 23 Sep 2010
Posts: 45
Location: United States

PostPosted: Sat Jun 16, 2012 1:10 pm    Post subject: SOLVED my first subbroutine Reply with quote

This is my first attempt at a subroutine. I WANT the subroutine to move data to a print line on an
OPEN OFFICE document

(code in macro)
Code:
REM  database name N_CENTRAL_DIRECTORY
Dim oProps(2) as New com.sun.star.beans.PropertyValue
DIM oOpts(1)  as New com.sun.star.beans.PropertyValue 
Dim oDoc         as Object         'Document to print.
DIM S_Desc       as OBJECT 

      (code in macro)
        HOLDLINE = LINEHOLD (1)
        HOLDDATA = RESULTSET.GETSTRING(2)
        CALL PRT_LINE
           

note: LINEHOLD () holds the field names used on the document


Sub PRT_LINE
DIM HOLDLINE  AS STRING
DIM HOLDDATA  AS STRING
DIM S_Desc    AS OBJECT
DIM oDoc      AS OBJECT
  MSGBOX "OOO"
     S_Desc = oDoc.createReplaceDescriptor()    <<<<< error here
 MSGBOX "PPP"     
       With S_Desc
           .SearchString = HOLDLINE
           .ReplaceString = HOLDDATA
           End With
     oDoc.ReplaceAll(S_Desc)
     LINE_CT = LINE_CT + 1
     J = J + 1
End Sub



<<<<<< error message Object variable not set

Thank You For Your Help

Steven

Tagged code - floris v, moderator


Last edited by STEVENSMITH100 on Mon Jul 23, 2012 1:24 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Sat Jun 16, 2012 10:15 pm    Post subject: Reply with quote

HOLDLINE = LINEHOLD (1)
what is LINEHOLD (1) ? this object is not defined
_________________
If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button).
Back to top
View user's profile Send private message
STEVENSMITH100
General User
General User


Joined: 23 Sep 2010
Posts: 45
Location: United States

PostPosted: Sun Jun 17, 2012 1:14 am    Post subject: Reply with quote

LINEHOLD is a 44 element array. Each element of the array is set to hold the field name on the document. example: LINEHOLD (1) = "linea" LINEHOLD (2) = "lineb" etc. I then keep up with the number of lines I have used to know when I have reached the end of the page and need to print the page and execute the header routine. I have been told more than once that I use too many lines of code. I hope that learning how to exec a subroutine will cut down on the size of my macos.
Back to top
View user's profile Send private message AIM Address
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Sun Jun 17, 2012 5:34 am    Post subject: Reply with quote

It's not easy to check only one part of your code
_________________
If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button).
Back to top
View user's profile Send private message
Sliderule
Super User
Super User


Joined: 29 May 2004
Posts: 2499
Location: 3rd Rock From The Sun

PostPosted: Sun Jun 17, 2012 6:30 am    Post subject: Reply with quote

STEVENSMITH100:

I do not understand why you are using a macro and print statements.

The OpenOffice Base application includes a report facility that I suspect you should use. After starting your Base application, click on Report icon on the bottom left.You can even use a Wizard to start your report. Reports are built from either:
  1. Tables
  2. Views
  3. Queries
And, if you download and install the more advanced Oracle Report Builder extension from:

http://extensions.services.openoffice.org/en/project/reportdesign

the report facility will control such things as page header, page footer, page content etc.

You can download a SAMPLE database, using Oracle Report Builder ( after you install the Oracle Report Builder in OpenOffice ) from:

http://www.mediafire.com/?q6ksrpaowgk6lsv

Sliderule

Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Sun Jun 17, 2012 11:42 am    Post subject: Reply with quote

Your noted error occurs because oDoc is not defined. Add
oDoc = ThisComponent
after your DIMs.
Back to top
View user's profile Send private message
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