Re: [libreoffice-users] Macro not active when the document start

2011-08-11 Thread Johnny Rosenberg
2011/8/10 Cor Nouws oo...@nouenoff.nl:

 toto wrote (10-08-11 09:23)

 I'm using macro's function and it doesn't start when the document start.

 You can change that via Tools  Customize  Events.
 Find the OnOpen event and link it to the macro for the document.

I think the function is supposed to be used as a cell function. Then
the event thing is not needed.




Regards

Johnny Rosenberg
ジョニー・ローゼンバーグ


 Regards,


 --
  - Cor
  - http://nl.libreoffice.org


 --
 For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
 Problems?
 http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
 Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
 List archive: http://listarchives.libreoffice.org/global/users/
 All messages sent to this list will be publicly archived and cannot be
 deleted



-- 
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted


Re: [libreoffice-users] Macro not active when the document start

2011-08-11 Thread Johnny Rosenberg
2011/8/10 toto t...@nurulfikri.com:
 I'm using macro's function and it doesn't start when the document start. It
 would start if I change the value of the variabel at the function. The code
 is to change numeric value to string. If I execute the code: ubah(123) the
 result is seratus dua puluh tiga. Any idea how to make the function
 executed when I open the document?

The macro is used as a cell function right?
In that case, where did you put the macro? It should be placed in My
Macros, I think, so you need to move it there if it's not there
already.



Regards

Johnny Rosenberg
ジョニー・ローゼンバーグ


 The code is:

 Public Function ubah(x as currency) as String
    Dim triliun As Currency
    Dim milyar As Currency
    Dim juta As Currency
    Dim ribu As Currency
    Dim satu As Currency
    Dim sen As Currency
    Dim baca As String
    If x  1 Then
       gusti =  Modul belum tersedia saat ini 
       Exit Function
    End If
    'Jika x adalah 0, maka dibaca sebagai 0
    If x = 0 Then
       baca = angka(0, 1)
    Else
       'Pisah masing-masing bagian untuk triliun, milyar, juta, ribu, rupiah,
 dan sen
       triliun = Int(x / 1000 ^ 4)
       milyar = Int((x - triliun * 1000 ^ 4) / 1000 ^ 3)
       juta = Int((x - triliun * 1000 ^ 4 - milyar * 1000 ^ 3) / 1000 ^ 2)
       ribu = Int((x - triliun * 1000 ^ 4 - milyar * 1000 ^ 3 - juta * 1000 ^
 2) / 1000)
       satu = Int(x - triliun * 1000 ^ 4 - milyar * 1000 ^ 3 - juta * 1000 ^
 2 - ribu * 1000)
       sen = Int((x - Int(x)) * 100)
       'Baca bagian triliun dan ditambah akhiran triliun
       If triliun  0 Then
          baca = ratus(triliun, 5) + triliun 
       End If
       'Baca bagian milyar dan ditambah akhiran milyar
       If milyar  0 Then
          baca = ratus(milyar, 4) + milyar 
       End If
       'Baca bagian juta dan ditambah akhiran juta
       If juta  0 Then
          baca = baca + ratus(juta, 3) + juta 
       End If
       'Baca bagian ribu dan ditambah akhiran ribu
       If ribu  0 Then
          baca = baca + ratus(ribu, 2) + ribu 
       End If
       'Baca bagian rupiah dan ditambah akhiran rupiah
       If satu  0 Then
          baca = baca + ratus(satu, 1)
       End If
       'Baca bagian sen dan ditambah akhiran sen
       If sen  0 Then
          baca = baca + ratus(sen, 0)
       End If
    End If
    ubah = UCase(Left(baca, 1))  LCase(Mid(baca, 2))
 End Function

 Function ratus(x As Currency, Posisi As Integer) As String
    Dim a100 As Integer, a10 As Integer, a1 As Integer
    Dim baca As String
    a100 = Int(x * 0.01)
    a10 = Int((x - a100 * 100) * 0.1)
    a1 = Int(x - a100 * 100 - a10 * 10)
    'Baca Bagian Ratus
    If a100 = 1 Then
       baca = Seratus 
    Else
       If a100  0 Then
          baca = angka(a100, Posisi) + ratus 
       End If
    End If
    'Baca Bagian Puluh dan Satuan
    If a10 = 1 Then
       baca = baca + angka(a10 * 10 + a1, Posisi)
    Else
       If a10  0 Then
          baca = baca + angka(a10, Posisi) + puluh 
       End If
       If a1  0 Then
          baca = baca + angka(a1, Posisi)
       End If
    End If
    ratus = baca
 End Function

 Function angka(x As Integer, Posisi As Integer)
    Select Case x
        Case 0: angka = Nol
        Case 1:
            If Posisi = 1 Or Posisi  2 Then
               angka = Satu 
            Else
               angka = Satu 
            End If
        Case 2: angka = Dua 
        Case 3: angka = Tiga 
        Case 4: angka = Empat 
        Case 5: angka = Lima 
        Case 6: angka = Enam 
        Case 7: angka = Tujuh 
        Case 8: angka = Delapan 
        Case 9: angka = Sembilan 
        Case 10: angka = Sepuluh 
        Case 11: angka = Sebelas 
        Case 12: angka = Duabelas 
        Case 13: angka = Tigabelas 
        Case 14: angka = Empatbelas 
        Case 15: angka = Limabelas 
        Case 16: angka = Enambelas 
        Case 17: angka = Tujuhbelas 
        Case 18: angka = Delapanbelas 
        Case 19: angka = Sembilanbelas 
    End Select
 End Function




 --
 For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
 Problems?
 http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
 Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
 List archive: http://listarchives.libreoffice.org/global/users/
 All messages sent to this list will be publicly archived and cannot be
 deleted



-- 
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted


[libreoffice-users] Macro not active when the document start

2011-08-10 Thread toto
I'm using macro's function and it doesn't start when the document start. 
It would start if I change the value of the variabel at the function. 
The code is to change numeric value to string. If I execute the code: 
ubah(123) the result is seratus dua puluh tiga. Any idea how to make 
the function executed when I open the document?


The code is:

Public Function ubah(x as currency) as String
Dim triliun As Currency
Dim milyar As Currency
Dim juta As Currency
Dim ribu As Currency
Dim satu As Currency
Dim sen As Currency
Dim baca As String
If x  1 Then
   gusti =  Modul belum tersedia saat ini 
   Exit Function
End If
'Jika x adalah 0, maka dibaca sebagai 0
If x = 0 Then
   baca = angka(0, 1)
Else
   'Pisah masing-masing bagian untuk triliun, milyar, juta, ribu, 
rupiah, dan sen

   triliun = Int(x / 1000 ^ 4)
   milyar = Int((x - triliun * 1000 ^ 4) / 1000 ^ 3)
   juta = Int((x - triliun * 1000 ^ 4 - milyar * 1000 ^ 3) / 1000 ^ 2)
   ribu = Int((x - triliun * 1000 ^ 4 - milyar * 1000 ^ 3 - juta * 
1000 ^ 2) / 1000)
   satu = Int(x - triliun * 1000 ^ 4 - milyar * 1000 ^ 3 - juta * 
1000 ^ 2 - ribu * 1000)

   sen = Int((x - Int(x)) * 100)
   'Baca bagian triliun dan ditambah akhiran triliun
   If triliun  0 Then
  baca = ratus(triliun, 5) + triliun 
   End If
   'Baca bagian milyar dan ditambah akhiran milyar
   If milyar  0 Then
  baca = ratus(milyar, 4) + milyar 
   End If
   'Baca bagian juta dan ditambah akhiran juta
   If juta  0 Then
  baca = baca + ratus(juta, 3) + juta 
   End If
   'Baca bagian ribu dan ditambah akhiran ribu
   If ribu  0 Then
  baca = baca + ratus(ribu, 2) + ribu 
   End If
   'Baca bagian rupiah dan ditambah akhiran rupiah
   If satu  0 Then
  baca = baca + ratus(satu, 1)
   End If
   'Baca bagian sen dan ditambah akhiran sen
   If sen  0 Then
  baca = baca + ratus(sen, 0)
   End If
End If
ubah = UCase(Left(baca, 1))  LCase(Mid(baca, 2))
End Function

Function ratus(x As Currency, Posisi As Integer) As String
Dim a100 As Integer, a10 As Integer, a1 As Integer
Dim baca As String
a100 = Int(x * 0.01)
a10 = Int((x - a100 * 100) * 0.1)
a1 = Int(x - a100 * 100 - a10 * 10)
'Baca Bagian Ratus
If a100 = 1 Then
   baca = Seratus 
Else
   If a100  0 Then
  baca = angka(a100, Posisi) + ratus 
   End If
End If
'Baca Bagian Puluh dan Satuan
If a10 = 1 Then
   baca = baca + angka(a10 * 10 + a1, Posisi)
Else
   If a10  0 Then
  baca = baca + angka(a10, Posisi) + puluh 
   End If
   If a1  0 Then
  baca = baca + angka(a1, Posisi)
   End If
End If
ratus = baca
End Function

Function angka(x As Integer, Posisi As Integer)
Select Case x
Case 0: angka = Nol
Case 1:
If Posisi = 1 Or Posisi  2 Then
   angka = Satu 
Else
   angka = Satu 
End If
Case 2: angka = Dua 
Case 3: angka = Tiga 
Case 4: angka = Empat 
Case 5: angka = Lima 
Case 6: angka = Enam 
Case 7: angka = Tujuh 
Case 8: angka = Delapan 
Case 9: angka = Sembilan 
Case 10: angka = Sepuluh 
Case 11: angka = Sebelas 
Case 12: angka = Duabelas 
Case 13: angka = Tigabelas 
Case 14: angka = Empatbelas 
Case 15: angka = Limabelas 
Case 16: angka = Enambelas 
Case 17: angka = Tujuhbelas 
Case 18: angka = Delapanbelas 
Case 19: angka = Sembilanbelas 
End Select
End Function




--
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted



Re: [libreoffice-users] Macro not active when the document start

2011-08-10 Thread Cor Nouws


toto wrote (10-08-11 09:23)

I'm using macro's function and it doesn't start when the document start.


You can change that via Tools  Customize  Events.
Find the OnOpen event and link it to the macro for the document.

Regards,


--
 - Cor
 - http://nl.libreoffice.org


--
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted



Re: [libreoffice-users] Macro not active when the document start

2011-08-10 Thread toto
The macro is active, but the function in the cell not active. Somehow I 
have to change the function variable with another value then I have to 
change it back again. So in the cell if I put =ubah(E7) I have to 
change it to =ubah(100) and then change it back again to =ubah(E7) 
to get the result that I want.


On 08/10/2011 03:16 PM, Cor Nouws wrote:


toto wrote (10-08-11 09:23)

I'm using macro's function and it doesn't start when the document start.


You can change that via Tools  Customize  Events.
Find the OnOpen event and link it to the macro for the document.

Regards,





--
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted