[Solved] Excel to OOffice calc

Discuss the spreadsheet application
Post Reply
ironpower
Posts: 4
Joined: Sun Nov 22, 2015 7:38 pm

[Solved] Excel to OOffice calc

Post by ironpower »

Hello I have this code in excel that saves the sheet in a PDF file, and put the name of pdf file the value of cell "E2", but in OpenOffice calc I can't put the name of pdf file the value of cell "E2"

VBA:

Code: Select all

Sub macrogravar()
'
' macrogravar Macro
'

'
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="D:\Caixadiario\ " & Range("e2") & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=True
    Range("H23").Select
End Sub


On the office calc I have this code:


sub gravarpdf
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(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///D:/caixadiario/ . pdf"
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
args1(2).Name = "FilterData"
.......
dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args1())


end sub
Last edited by Hagar Delest on Mon Nov 23, 2015 11:37 pm, edited 1 time in total.
Reason: tagged [Solved].
openoffice 4.1.2 windows XP
User avatar
Villeroy
Volunteer
Posts: 31348
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Excel to OOffice calc

Post by Villeroy »

If you would spend some 15 minutes with some text about OpenOffice macro programming, reading from and writing to cells would be plain obvious.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
ironpower
Posts: 4
Joined: Sun Nov 22, 2015 7:38 pm

Re: Excel to OOffice calc

Post by ironpower »

Thanks for the help, it's always easy when people have the knowlodge. :super:
openoffice 4.1.2 windows XP
User avatar
Villeroy
Volunteer
Posts: 31348
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Excel to OOffice calc

Post by Villeroy »

We are no human macro recorders. There are many millions of foolish VBA macros.
Last edited by Villeroy on Sun Nov 22, 2015 10:26 pm, edited 1 time in total.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11495
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Excel to OOffice calc

Post by Zizi64 »

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
ironpower
Posts: 4
Joined: Sun Nov 22, 2015 7:38 pm

Re: Excel to OOffice calc

Post by ironpower »

Thanks for the help, I'm reading the docs, and I'm trying to fix my problem.
openoffice 4.1.2 windows XP
User avatar
Zizi64
Volunteer
Posts: 11495
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Excel to OOffice calc

Post by Zizi64 »

From the linked pages (it is not a complete code but snippets only:

Code: Select all

Dim oDoc as object
Dim oSheet as object
Dim oCell as object
Dim MyText as string

'Get the active document:
oDoc = Thiscomponent


'Get a sheet by index:
oSheet = ThisComponent.Sheets(0)

'Get a sheet by name:
oSheets = oDoc.Sheets  'get the container of all Sheets
oSheet = oSheets.getByName("Sheet2")   'get the sheet named Sheet2

'Get the active sheet:
oSheet=oDoc.getcurrentcontroller.activesheet


'Get a cell by position:
oCell=oSheet.getCellByPosition(0,0) 'These coordinates means: the cell A1


'Get text from a cell:
MyText = oCell.string


'Put the text into the args1:
args1(0).Value = "file:///D:/caixadiario/" + MyText + ". pdf"

Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
ironpower
Posts: 4
Joined: Sun Nov 22, 2015 7:38 pm

Re: Excel to OOffice calc

Post by ironpower »

Thanks a lot for your help, I did same changes, but your code it was perfect.
Thanks :D
openoffice 4.1.2 windows XP
Post Reply