Page 1 of 1

[Solved] Building a macro for inserting section

PostPosted: Tue Oct 08, 2019 3:36 pm
by roberto.vieira
I think I fall in almost the same case as merbeth.

I´m replacing MS Office by Libre Office in an VB.Net (VS 2010) desktop application.

Running the writerdemo, I could run the application.

Now, when I replaced code calling to Writer instead of MS Word, the application the executes the word processor is not compiled. I get no error messages, but I get one warning that says "There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "cli_cppuhelper", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project."

I already built as x86 and as x64, but I get no compilation of the application. To me, seems like the dll´s were built with AMD64 architeture. I tried also naming as "AMD64", but no solution.

Can you give me some help ?

Roberto Camargo / Rio de Janeiro

Re: Cannot find dll on Win7 64 Bit

PostPosted: Wed Oct 09, 2019 7:06 pm
by Villeroy
Install the 64-bit variant of LibreOffice for Windows.

Re: Cannot find dll on Win7 64 Bit

PostPosted: Wed Oct 09, 2019 8:54 pm
by roberto.vieira
About the previous thread I wrote, it was resolved after installing the most recente dayly compile.

Villeroy, thanks, I´m already using x64 version.

After this, I got that application compiled.

Thanks,
Roberto Camargo.

Building a macro for inserting section

PostPosted: Thu Oct 24, 2019 11:18 pm
by roberto.vieira
Dears,

I looked all over the history, and other papers, and I didn´t find any example of how to insert section in a document.

I´m working a code for replacing the msword by libre, and there exist two sections that I insert.

I´m doing it with VB.Net, but giving me some idea how doing this as a Basic macro, will be of a great help.

Using the Object Inspector, I opened the branch "XTextSectionsSupplier", hoping to find there something sounding as the way to resolve this, but I couldn´t.

Could you be kind helping me to resolve this ?

In advance, my best thanks,
Roberto Vieira.

Re: Cannot find dll on Win7 64 Bit

PostPosted: Thu Oct 24, 2019 11:32 pm
by Lupp
Please don't hitchhike unrelated threads.

http://www.pitonyak.org/AndrewMacro.pdf 7.25.1

Re: Cannot find dll on Win7 64 Bit

PostPosted: Thu Oct 24, 2019 11:38 pm
by Villeroy
Keep your MS Office solution for ever.

Re: Cannot find dll on Win7 64 Bit

PostPosted: Thu Oct 24, 2019 11:52 pm
by roberto.vieira
Thx, Lupp, for your repply.

Beside others, and searching over all, I read many times the indicated paper, and, as I told, I could´nt arrive to a solution. But, it was there that I found the XTextSectionsSupplier service. Starting from this, I looked at the Object Inspector, hoping to find some method to insert.

I know that many ways the codes are implemented at OO Basic is very different than VB. And, yet coming since DOS 3.2, with OO Basic I´m very new.

Re: Building a macro for inserting section

PostPosted: Fri Oct 25, 2019 1:22 pm
by DiGro
Roberto, have a look at this:

https://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Sections

Maybe that will help you further

Re: Building a macro for inserting section

PostPosted: Fri Oct 25, 2019 1:45 pm
by JeJe
Useful Macro Information
For OpenOffice
By
Andrew Pitonyak

Listing 7.57

Code: Select all   Expand viewCollapse view
Sub AddTextSection
Dim oSect
Dim sName$
Dim oVC
Dim oText
Dim oCols
Dim s$
sName = "ADPSection"
If ThisComponent.getTextSections().hasByName(sName) Then
Print "Text section " & sName & " Already exists"
oSect = ThisComponent.getTextSections().getByName(sName)
Else
REM Create a text section at the cursor
oVC = ThisComponent.getCurrentController().getViewCursor()
oText = oVC.getText()
REM Insert a new paragraph
oText.insertControlCharacter(oVC, _
com.sun.star.text.ControlCharacter.LINE_BREAK, False)
REM Insert a new paragraph and select it
oText.insertControlCharacter(oVC, _
com.sun.star.text.ControlCharacter.LINE_BREAK, True)
s = "com.sun.star.text.TextSection"
oSect = ThisComponent.createInstance(s)
oSect.setName(sName)
REM Now, create the columns...
s = "com.sun.star.text.TextColumns"
oCols = ThisComponent.createInstance(s)
oCols.setColumnCount(2)
oSect.TextColumns = oCols
187
oText.insertTextContent(oVC, oSect, True)
oText.insertString(oVC, "This is new text. " & _
"I suppose that I could count and repeat myself as " & _
"an example of how text can go on and on and on. " & _
"I suppose that I could count and repeat myself as " & _
"an example of how text can go on and on and on. " & _
"I suppose that I could count and repeat myself as " & _
"an example of how text can go on and on and on. " & _
"I suppose that I could count and repeat myself as " & _
"an example of how text can go on and on and on. " & _
"I suppose that I could count and repeat myself as " & _
"an example of how text can go on and on and on. " & _
"I suppose that I could count and repeat myself as " & _
"an example of how text can go on and on and on. " & _
"And finally I will stop.", True)
Print "Created the text section"
End If
oCols = oSect.TextColumns
Dim OC()
OC() = oCols.getColumns()
REM Set the right margin on the first column to 1/4 inch.
OC(0).RightMargin = 635
REM Set the left margin on the second column to 1/4 inch.
OC(1).LeftMargin = 635
oCols.setColumns(OC())
oSect.TextColumns = oCols
End Sub

Re: Building a macro for inserting section

PostPosted: Fri Oct 25, 2019 2:58 pm
by roberto.vieira
Thanks a lot, Jeje, it looks like going to the point, I will adapt to my needs.

Have a nice day !