[Solved] Did the macro steal my row?

Discuss the spreadsheet application
Post Reply
alweiss
Posts: 20
Joined: Fri Feb 20, 2009 2:07 am

[Solved] Did the macro steal my row?

Post by alweiss »

I had a problem which I can not believe is unique to me. I maintain a roster that I have to distribute to a number of people, some of whom do not have a spreadsheet program. I wanted a date indicating when it was last updated to show in the spreadsheet and I also wanted to save a copy as a pdf. Relying on my memory to remember to enter the date and then export it to a pdf was not working.

Someone supplied me with a macro that would do the job. It is:

Code: Select all

Sub Main
Dim Doc, Sheet, Cell as Object
Dim PropVals(0) as New com.sun.star.beans.PropertyValue
Dim FileName as String
Doc = ThisComponent                 'Get the current document.
Sheet = Doc.Sheets(0)               'Picks the leftmost sheet
Cell = Sheet.getCellByPosition(1,0) 'Assigns cell B1 as the target for the Date
Cell.String = Date
FileName = convertToURL("C:\Users\XXXXX\Documents\Temp.pdf")
PropVals(0).Name = "FilterName"
PropVals(0).Value = "calc_pdf_Export"
Doc.storeToURL(FileName, PropVals()
End Sub
However, when I save the spreadsheet (which I have reduced to 3 rows and 2 columns for testing) the pdf only has 2 rows and 2 columns. Row 1 has disappeared. Anyone know where it has gone?

P.S., The same thing happens if I manually export it as a pdf.

P.P.S., The ods file is available at http://tinyurl.com/odsfile. (You will have to change the folder name from XXXXX in the macro.) The pdf file is at http://tinyurl.com/2cknlm2. (tinyurl/pdffile was not available.)

P.P.P.S., I'm running OOCalc version 3.2.0 under Windows Vista.
Last edited by Hagar Delest on Sun Aug 29, 2010 9:25 pm, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.0.X on MS Windows Vista
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Did the macro steal my row?

Post by rudolfo »

I could reproduce what you describe. But my guess is that the root of the problem is not the macro but your page layout. If you print the page or use print preview the first line is not included, as well.
Below the sheet's name "Residents" you will see PageStyle_Residents as the active page style. This has a rather never ending list of changes to the default style, see attached screenshot.
settings for PageStyle_Residents
settings for PageStyle_Residents
pagestyle.png (7.93 KiB) Viewed 1331 times
And there is another cell style "Excel_Builtin_Comma" which makes me guess that the file was imported from or initially created by MS Excel (all revealed by pressing F11, to open the stylist).

So the answer is: simplify your page layout: Start from a fresh OOo Spreadsheet template. Or use another page style and try again.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Did the macro steal my row?

Post by Charlie Young »

Look at Format > Print Ranges Edit. It's set to A2:B3.
Apache OpenOffice 4.1.1
Windows XP
alweiss
Posts: 20
Joined: Fri Feb 20, 2009 2:07 am

Re: Did the macro steal my row?

Post by alweiss »

:oops: DUH!

I have no idea how it got that way but, as soon as I corrected it, the whole problem went away.

Thanks,
Al
OOo 3.0.X on MS Windows Vista
Post Reply