OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Macro not working when created in library module

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
prasad.sauravkumar
Newbie
Newbie


Joined: 04 Mar 2012
Posts: 3

PostPosted: Sun Mar 04, 2012 12:11 am    Post subject: Macro not working when created in library module Reply with quote

Rem Attribute VBA_ModuleType=VBAModule

Function genscript()


Dim MyFile As String
Dim Outputfile As String
Dim startrow As Integer

startrow = Int(Cells(3, 2))
'MyFile = Cells(2, 2) '"c:\" & "a.txt"
MyFile = ThisWorkbook.Path & "\output" & Fn_saveas_filename & ".txt"

i = startrow
fnum = FreeFile()
Open MyFile For Output As fnum
Do Until Cells(i, 1) = ""
Print #fnum, "create user " & Cells(i, 1); " IDENTIFIED BY " & Cells(i, 2) & ";" & vbCrLf
Print #fnum, "grant sse_role to " & Cells(i, 1) & ";" & vbCrLf
Print #fnum, "alter user " & Cells(i, 1); " quota 0 on system" & ";" & vbCrLf
Print #fnum, "alter user " & Cells(i, 1); " default tablespace data_siebel " & ";" & vbCrLf
Print #fnum, "alter user " & Cells(i, 1); " temporary tablespace temp" & ";" & vbCrLf
Print #fnum, "commit" & ";" & vbCrLf
i = i + 1
Loop
Close #fnum


iResponse = MsgBox(Prompt:="Script Generated sucessfully" & vbCrLf & "Do you want to open the File?", _
Buttons:=vbYesNo + vbInformation)

Select Case iResponse

Case vbYes

intResult = Shell("Notepad.exe " & MyFile, vbNormalFocus)


End Select

End Function


Function Fn_saveas_filename() As String

If Len(Month(Now)) = 1 Then
new_month = "0" & Month(Now)
Else
new_month = Month(Now)
End If

If Len(Day(Now)) = 1 Then
new_day = "0" & Day(Now)
Else
new_day = Day(Now)
End If

If Len(Hour(Time)) = 1 Then
new_hour = "0" & Hour(Time)
Else
new_hour = Hour(Time)
End If

If Len(Minute(Time)) = 1 Then
new_minute = "0" & Minute(Time)
Else
new_minute = Minute(Time)
End If

If Len(Second(Time)) = 1 Then
new_second = "0" & Second(Time)
Else
new_second = Second(Time)
End If


Fn_saveas_filename = Year(Now) & new_month & new_day & new_hour & new_minute & new_second

End Function
====================================
this whole coding runs when i use in excel and OOG. but when i assign this macro to a toolbar menu in OOG, it throws error " sub procedure or function procedure not defined "
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Sun Mar 04, 2012 12:48 am    Post subject: Reply with quote

Hello

I think your macros are not loaded. Place them in the standard library.

Romke
Back to top
View user's profile Send private message
prasad.sauravkumar
Newbie
Newbie


Joined: 04 Mar 2012
Posts: 3

PostPosted: Sun Mar 04, 2012 2:18 am    Post subject: Reply with quote

RPG wrote:
Hello

same error in standard library. can u tell me how to save it as addin in oog.

Romke
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Sun Mar 04, 2012 3:59 am    Post subject: Reply with quote

Hello

My advice is try to understand how OOo is working.

I think make a text database and use that.

Romke
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Sun Mar 04, 2012 5:41 am    Post subject: Reply with quote

Quote:
this whole coding runs when i use in excel and OOG. but when i assign this macro to a toolbar menu in OOG, it throws error " sub procedure or function procedure not defined "
(...)
can u tell me how to save it as addin in oog.

Excuse my ignorance, what is OOG ?

Are you aware that Excel VBA and OpenOffice.org macros are two different things ?
_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
prasad.sauravkumar
Newbie
Newbie


Joined: 04 Mar 2012
Posts: 3

PostPosted: Sun Mar 04, 2012 9:44 am    Post subject: Reply with quote

oog is short for open office org.

ya i know the difference b/w excel n oog calc.

question is same thing runs in oog when the macro is added in workbook module.

but when i add the macro to library... it throws error.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group