gegevens van besturingselementen bewerken met een macro

Status
Niet open voor verdere reacties.

Offshore

Nieuwe gebruiker
Lid geworden
12 okt 2009
Berichten
3
Hallo mijn bedoeling is om gegevens van besturingselementen te bewerken met een macro, echter wil dit niet zo lukken.

De bedoeling is dat ik in een formulier gegevens in div. tekstboxen plaats en dat die macro dat dan voor me uit rekent en de uitkomst weer in een anderen tekstbox plaatst zodat ik ze dan kan opslag in een tabel.

Het volgende deel van de macro heb ik al, maar deze is nog niet compleet en werkt dus niet.
Code:
REM  *****  BASIC  *****
Option Explicit

Sub main
End sub

Sub berekening (oEvent)

Dim s$
Dim oForm
Dim oDoc     
Dim oCon               

  oForm = oEvent.Source.getModel().getParent()
'  oDoc = oForm


'  s = "com.sun.star.text.TextDocument"
'  Do While NOT oDoc.supportsService(s)
'    oDoc = oDoc.getParent()

'  oForm.getByName("TextBox").setString(s)

Dim FacAan0 As Double 
Dim FacAan01 As Double
Dim FacAan02 As Double
Dim FacAan03 As Double
Dim FacAan04 As Double
Dim FacAan05 As Double
Dim FacAan06 As Double
Dim FacAan07 As Double
Dim FacAan08 As Double
Dim FacAan09 As Double

FacAan0 = oForm.getByName("FacAan0").getDouble
FacAan01 = oForm.getByName("FacAan01").getDouble
FacAan02 = oForm.getByName("FacAan02").getDouble
FacAan03 = oForm.getByName("FacAan03").getDouble
FacAan04 = oForm.getByName("FacAan04").getDouble
FacAan05 = oForm.getByName("FacAan05").getDouble
FacAan06 = oForm.getByName("FacAan06").getDouble
FacAan07 = oForm.getByName("FacAan07").getDouble
FacAan08 = oForm.getByName("FacAan08").getDouble
FacAan09 = oForm.getByName("FacAan09").getDouble

Dim FacPrijs0 As Double
Dim FacPrijs01 As Double
Dim FacPrijs02 As Double
Dim FacPrijs03 As Double
Dim FacPrijs04 As Double
Dim FacPrijs05 As Double
Dim FacPrijs06 As Double
Dim FacPrijs07 As Double
Dim FacPrijs08 As Double
Dim FacPrijs09 As Double

FacPrijs0 = oForm.getByName("FacPrijs0").getDouble
FacPrijs01 = oForm.getByName("FacPrijs01").getDouble
FacPrijs02 = oForm.getByName("FacPrijs02").getDouble
FacPrijs03 = oForm.getByName("FacPrijs03").getDouble
FacPrijs04 = oForm.getByName("FacPrijs04").getDouble
FacPrijs05 = oForm.getByName("FacPrijs05").getDouble
FacPrijs06 = oForm.getByName("FacPrijs06").getDouble
FacPrijs07 = oForm.getByName("FacPrijs07").getDouble
FacPrijs08 = oForm.getByName("FacPrijs08").getDouble
FacPrijs09 = oForm.getByName("FacPrijs09").getDouble

Dim FacTot0 As Double
Dim FacTot01 As Double
Dim FacTot02 As Double
Dim FacTot03 As Double
Dim FacTot04 As Double
Dim FacTot05 As Double
Dim FacTot06 As Double
Dim FacTot07 As Double
Dim FacTot08 As Double
Dim FacTot09 As Double

Dim BTWpre As Double
Dim FacTotExcl As Double
Dim FacTotBTW As Double
Dim FacTotIncl As Double

FacTot0 = FacAan0 * FacPrijs0
FacTot01 = FacAan01 * FacPrijs01
FacTot02 = FacAan02 * FacPrijs02
FacTot03 = FacAan03 * FacPrijs03
FacTot04 = FacAan04 * FacPrijs04
FacTot05 = FacAan05 * FacPrijs05
FacTot06 = FacAan06 * FacPrijs06
FacTot07 = FacAan07 * FacPrijs07
FacTot08 = FacAan08 * FacPrijs08
FacTot09 = FacAan09 * FacPrijs09

BTWpre = oForm.getByName("BTWpre").getDouble
FacTotExcl = FacTot0 + FacTot01 + FacTot02 + FacTot03 + FacTot04 + FacTot05 + FacTot06 + FacTot07 + FacTot08 + FacTot09
FacTotBTW = FacTotExcl * BTWpre
FacTotIncl = FacTotExcl + FacTotBtw

oForm.getByName("FacTot0").updateDouble( FacTot0 )
oForm.getByName("FacTot01").updateDouble( FacTot01 )
oForm.getByName("FacTot02").updateDouble( FacTot02 )
oForm.getByName("FacTot03").updateDouble( FacTot03 )
oForm.getByName("FacTot04").updateDouble( FacTot04 )
oForm.getByName("FacTot05").updateDouble( FacTot05 )
oForm.getByName("FacTot06").updateDouble( FacTot06 )
oForm.getByName("FacTot07").updateDouble( FacTot07 )
oForm.getByName("FacTot08").updateDouble( FacTot08 )
oForm.getByName("FacTot09").updateDouble( FacTot09 )

oForm.getByName("FacTotExcl").updateDouble( FacTotExcl )
oForm.getByName("FacTotBTW").updateDouble( FacTotBTW )
' oForm.getByName("FacTotIncl").updateDouble( FacTotIncl )

End sub
Het grote probleem is voor al de gegevens uitwisseling ik krijg gewoon geen gegevens in en uit de macro, het probleem ligt mijn inziens in het volgende stukje wat niet goed is.
Code:
Dim s$
Dim oForm
Dim oDoc     
Dim oCon               

  oForm = oEvent.Source.getModel().getParent()
'  oDoc = oForm


'  s = "com.sun.star.text.TextDocument"
'  Do While NOT oDoc.supportsService(s)
'    oDoc = oDoc.getParent()
 
Nog een macro geprobeerd maar ook deze werkt niet
Code:
REM  *****  BASIC  *****
Option Explicit

Sub main
End sub

Sub berekening (oEvent)              

Dim oForm As Variant 

oForm = oEvent.Source.Model.Parent
with oForm.columns
  
Dim FacAan0 As Double 
Dim FacAan01 As Double
Dim FacAan02 As Double
Dim FacAan03 As Double
Dim FacAan04 As Double
Dim FacAan05 As Double
Dim FacAan06 As Double
Dim FacAan07 As Double
Dim FacAan08 As Double
Dim FacAan09 As Double

FacAan0 = oForm.getByName("FacAan0").getDouble
FacAan01 = oForm.getByName("FacAan01").getDouble
FacAan02 = oForm.getByName("FacAan02").getDouble
FacAan03 = oForm.getByName("FacAan03").getDouble
FacAan04 = oForm.getByName("FacAan04").getDouble
FacAan05 = oForm.getByName("FacAan05").getDouble
FacAan06 = oForm.getByName("FacAan06").getDouble
FacAan07 = oForm.getByName("FacAan07").getDouble
FacAan08 = oForm.getByName("FacAan08").getDouble
FacAan09 = oForm.getByName("FacAan09").getDouble

Dim FacPrijs0 As Double
Dim FacPrijs01 As Double
Dim FacPrijs02 As Double
Dim FacPrijs03 As Double
Dim FacPrijs04 As Double
Dim FacPrijs05 As Double
Dim FacPrijs06 As Double
Dim FacPrijs07 As Double
Dim FacPrijs08 As Double
Dim FacPrijs09 As Double

FacPrijs0 = oForm.getByName("FacPrijs0").getDouble
FacPrijs01 = oForm.getByName("FacPrijs01").getDouble
FacPrijs02 = oForm.getByName("FacPrijs02").getDouble
FacPrijs03 = oForm.getByName("FacPrijs03").getDouble
FacPrijs04 = oForm.getByName("FacPrijs04").getDouble
FacPrijs05 = oForm.getByName("FacPrijs05").getDouble
FacPrijs06 = oForm.getByName("FacPrijs06").getDouble
FacPrijs07 = oForm.getByName("FacPrijs07").getDouble
FacPrijs08 = oForm.getByName("FacPrijs08").getDouble
FacPrijs09 = oForm.getByName("FacPrijs09").getDouble

Dim FacTot0 As Double
Dim FacTot01 As Double
Dim FacTot02 As Double
Dim FacTot03 As Double
Dim FacTot04 As Double
Dim FacTot05 As Double
Dim FacTot06 As Double
Dim FacTot07 As Double
Dim FacTot08 As Double
Dim FacTot09 As Double

Dim BTWpre As Double
Dim FacTotExcl As Double
Dim FacTotBTW As Double
Dim FacTotIncl As Double

FacTot0 = FacAan0 * FacPrijs0
FacTot01 = FacAan01 * FacPrijs01
FacTot02 = FacAan02 * FacPrijs02
FacTot03 = FacAan03 * FacPrijs03
FacTot04 = FacAan04 * FacPrijs04
FacTot05 = FacAan05 * FacPrijs05
FacTot06 = FacAan06 * FacPrijs06
FacTot07 = FacAan07 * FacPrijs07
FacTot08 = FacAan08 * FacPrijs08
FacTot09 = FacAan09 * FacPrijs09

BTWpre = oForm.getByName("BTWpre").getDouble
FacTotExcl = FacTot0 + FacTot01 + FacTot02 + FacTot03 + FacTot04 + FacTot05 + FacTot06 + FacTot07 + FacTot08 + FacTot09
FacTotBTW = FacTotExcl * BTWpre
FacTotIncl = FacTotExcl + FacTotBtw

oForm.getByName("FacTot0").updateDouble( FacTot0 )
oForm.getByName("FacTot01").updateDouble( FacTot01 )
oForm.getByName("FacTot02").updateDouble( FacTot02 )
oForm.getByName("FacTot03").updateDouble( FacTot03 )
oForm.getByName("FacTot04").updateDouble( FacTot04 )
oForm.getByName("FacTot05").updateDouble( FacTot05 )
oForm.getByName("FacTot06").updateDouble( FacTot06 )
oForm.getByName("FacTot07").updateDouble( FacTot07 )
oForm.getByName("FacTot08").updateDouble( FacTot08 )
oForm.getByName("FacTot09").updateDouble( FacTot09 )

oForm.getByName("FacTotExcl").updateDouble( FacTotExcl )
oForm.getByName("FacTotBTW").updateDouble( FacTotBTW )
oForm.getByName("FacTotIncl").updateDouble( FacTotIncl )

End with

End sub
 
Pff weer wat verder, de besturingselementen wisselen nu info uit met de macro.
Enkel klopt de berekening niet maar ik zal wel andere variabelen moeten declareren.
Code:
REM  *****  BASIC  *****
Option Explicit

Sub main (oEvent)
Dim oForm As Variant 

oForm = oEvent.Source.Model.Parent
with oForm.columns

Dim FacAan0 As Double 
Dim FacAan01 As Double
Dim FacAan02 As Double
Dim FacAan03 As Double
Dim FacAan04 As Double
Dim FacAan05 As Double
Dim FacAan06 As Double
Dim FacAan07 As Double
Dim FacAan08 As Double
Dim FacAan09 As Double

FacAan0 = .getByName("FacAan0").getDouble
FacAan01 = .getByName("FacAan01").getDouble
FacAan02 = .getByName("FacAan02").getDouble
FacAan03 = .getByName("FacAan03").getDouble
FacAan04 = .getByName("FacAan04").getDouble
FacAan05 = .getByName("FacAan05").getDouble
FacAan06 = .getByName("FacAan06").getDouble
FacAan07 = .getByName("FacAan07").getDouble
FacAan08 = .getByName("FacAan08").getDouble
FacAan09 = .getByName("FacAan09").getDouble


Dim FacPrijs0 As Double
Dim FacPrijs01 As Double
Dim FacPrijs02 As Double
Dim FacPrijs03 As Double
Dim FacPrijs04 As Double
Dim FacPrijs05 As Double
Dim FacPrijs06 As Double
Dim FacPrijs07 As Double
Dim FacPrijs08 As Double
Dim FacPrijs09 As Double

FacPrijs0 = .getByName("FacPrijs0").getDouble
FacPrijs01 = .getByName("FacPrijs01").getDouble
FacPrijs02 = .getByName("FacPrijs02").getDouble
FacPrijs03 = .getByName("FacPrijs03").getDouble
FacPrijs04 = .getByName("FacPrijs04").getDouble
FacPrijs05 = .getByName("FacPrijs05").getDouble
FacPrijs06 = .getByName("FacPrijs06").getDouble
FacPrijs07 = .getByName("FacPrijs07").getDouble
FacPrijs08 = .getByName("FacPrijs08").getDouble
FacPrijs09 = .getByName("FacPrijs09").getDouble

Dim FacTot0 As Double
Dim FacTot01 As Double
Dim FacTot02 As Double
Dim FacTot03 As Double
Dim FacTot04 As Double
Dim FacTot05 As Double
Dim FacTot06 As Double
Dim FacTot07 As Double
Dim FacTot08 As Double
Dim FacTot09 As Double

Dim BTWpre As Double
Dim FacTotExcl As Double
Dim FacTotBTW As Double
Dim FacTotIncl As Double

FacTot0 = FacAan0 * FacPrijs0
FacTot01 = FacAan01 * FacPrijs01
FacTot02 = FacAan02 * FacPrijs02
FacTot03 = FacAan03 * FacPrijs03
FacTot04 = FacAan04 * FacPrijs04
FacTot05 = FacAan05 * FacPrijs05
FacTot06 = FacAan06 * FacPrijs06
FacTot07 = FacAan07 * FacPrijs07
FacTot08 = FacAan08 * FacPrijs08
FacTot09 = FacAan09 * FacPrijs09

'BTWpre = .getByName("BTWpre").getDouble
'FacTotExcl = FacTot0 + FacTot01 + FacTot02 + FacTot03 + FacTot04 + FacTot05 + FacTot06 + FacTot07 + FacTot08 + FacTot09
'FacTotBTW = FacTotExcl * BTWpre
'FacTotIncl = FacTotExcl + FacTotBtw

.getByName("FacTot0").updateDouble( FacTot0 )
.getByName("FacTot01").updateDouble( FacTot01 )
.getByName("FacTot02").updateDouble( FacTot02 )
.getByName("FacTot03").updateDouble( FacTot03 )
.getByName("FacTot04").updateDouble( FacTot04 )
.getByName("FacTot05").updateDouble( FacTot05 )
.getByName("FacTot06").updateDouble( FacTot06 )
.getByName("FacTot07").updateDouble( FacTot07 )
.getByName("FacTot08").updateDouble( FacTot08 )
.getByName("FacTot09").updateDouble( FacTot09 )

'.getByName("FacTotExcl").updateDouble( FacTotExcl )
'.getByName("FacTotBTW").updateDouble( FacTotBTW )
'.getByName("FacTotIncl").updateDouble( FacTotIncl )

End with

MsgBox ("Einde berekening", 0, "Test")

End sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan