| View previous topic :: View next topic |
| Author |
Message |
STEVENSMITH100 General User

Joined: 23 Sep 2010 Posts: 39 Location: United States
|
Posted: Sat Jun 16, 2012 1:10 pm Post subject: SOLVED my first subbroutine |
|
|
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 |
|
 |
patel Power User

Joined: 14 Apr 2012 Posts: 54 Location: Italy
|
Posted: Sat Jun 16, 2012 10:15 pm Post subject: |
|
|
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 |
|
 |
STEVENSMITH100 General User

Joined: 23 Sep 2010 Posts: 39 Location: United States
|
Posted: Sun Jun 17, 2012 1:14 am Post subject: |
|
|
| 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 |
|
 |
patel Power User

Joined: 14 Apr 2012 Posts: 54 Location: Italy
|
Posted: Sun Jun 17, 2012 5:34 am Post subject: |
|
|
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 |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2474 Location: 3rd Rock From The Sun
|
Posted: Sun Jun 17, 2012 6:30 am Post subject: |
|
|
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:
- Tables
- Views
- 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 |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8984 Location: Lexinton, Kentucky, USA
|
Posted: Sun Jun 17, 2012 11:42 am Post subject: |
|
|
Your noted error occurs because oDoc is not defined. Add
oDoc = ThisComponent
after your DIMs. |
|
| Back to top |
|
 |
|