Code VBA to Basic (error)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
ironbrothers
Posts: 1
Joined: Tue Dec 12, 2017 10:27 pm

Code VBA to Basic (error)

Post by ironbrothers »

Hello, I have on code in VBA, but my Sister on her store just have OpenOffice, and the code that I wrote doesnt match, anyone can help me?
I want that in the same cell, I can put one value, and continous insert values and the sum appears in to cells foward.

Code: Select all

Rem Attribute VBA_ModuleType=VBADocumentModule
Option VBASupport 1
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim vRange As Range

If Target.Cells.Count > 4 Then Exit Sub

Set vRange = Range("B12", "L21")

If Not Intersect(Target, vRange) Is Nothing Then
If IsNumeric(Target) And IsNumeric(Target.Offset(0, 2)) Then
Target.Offset(0, 2) = Target + Target.Offset(0, 2) 'pulando uma coluna e inserindo a soma
End If
End If
Set vRange = Nothing
End Sub
Please help me
Last edited by robleyd on Wed Dec 13, 2017 1:25 am, edited 1 time in total.
Reason: Add Code tags [robleyd, moderator]
Openoffice 4.4.1 on Windows 7
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Code VBA to Basic (error)

Post by Lupp »

I can only guess what the code is expected to achieve, and I don't feel sure there are many contributors here who know better.

Since you wrote the code, you will know. Tell us, and someone can surely write a few lines in native code for AOO Calc defining an equivalent Sub.
Don't miss to explain for what reason the local variable VRange is set to 'Nothing' at the end, and in what way you intend to call the Sub and to pass an 'Excel.Range' to it. It won't be surprising to you that the position from where the Sub is to call must know how to create that range, in other words tghat it must run undert VBAsupport. I assume you won't get happy with that miximg up of software with alien user code. Support in Calc will never be perfect. For what reason is the Sub declared 'Private'?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Zizi64
Volunteer
Posts: 11362
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Code VBA to Basic (error)

Post by Zizi64 »

Openoffice 4.4.1 on Windows 7
There is not Apache OpenOffice 4.4.1 version today.
If you are using LibreOffice, please update your signature.

The LibreOffice has a littlebit higher compatibility with the foreign fileformats and the MS VBA macros.
Try it.
Otherwise you must REWRITE all of your macros in StarBasic (or in other supported programming language: python for example) and based on the API (Application Programming Interface) functions.

Note - as Lupp wrote it - "Support in Calc will never be perfect." Neither in AOO nor in LO.
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.
Post Reply