Page 1 of 1

Macro is not running when my file is newly open

PostPosted: Thu May 10, 2018 5:03 am
by j0n
Hi,

I'm a newbie in OOO, i have a calc file and every time i open it, macro didn't work.
I need to edit the macro to make it run.
I know there's wrong with my code, and i Cant find it..:(

Re: Macro is not running when my file is newly open

PostPosted: Thu May 10, 2018 5:48 am
by FJCC
Please post your macro code and what you want it to do. Also, what edit do you make to the macro to make it run?

Re: Macro is not running when my file is newly open

PostPosted: Thu May 10, 2018 6:03 am
by j0n
Hi,

i tried to attach the file but it was too big.
Here's the process.
First there's a login form connected to a local database. Once successful it will proceed to another form that use the codes below.
if i newly open the file, the combobox is not working but if i edit the macro like put a space in any line and run the process again, it will work.


Code: Select all   Expand viewCollapse view

Private Sub btnok_Click()

If txtacd.Text = "" Then
   lblnotifok.caption = "Please provide ACD Number!"
ElseIf txtmobilenumber.Text = "" Then
   lblnotifok.caption = "Please provide Mobile Number!"
ElseIf txtsubsname.Text = "" Then
   lblnotifok.caption = "Please provide Subscribers Name!"

ElseIf len(lblnotifmobile.caption) > 5 then
goto Err1

Elseif len(lblnotifname.caption) > 5 then
goto Err1

Elseif len(lblnotifacd.caption) > 5 then
goto Err1

Err1:   
lblnotifok.caption =  lblnotifacd.caption & vbNewLine & lblnotifmobile.caption & vbNewLine & lblnotifname.caption
   
Else
newmainform.Hide
newhandsetavailment.ComboBox1.Text = ""
newhandsetavailment.ComboBox2.Text = ""
newhandsetavailment.ComboBox3.Text = ""
newhandsetavailment.ComboBox4.Text = ""
newhandsetavailment.ComboBox1.Enabled = False
newhandsetavailment.ComboBox2.Enabled = False
newhandsetavailment.ComboBox3.Enabled = False
newhandsetavailment.ComboBox4.Enabled = False


newrewards.Show
End If
End Sub

Private Sub btnsave_Click()

lblnotifacd.caption = ""

If txtmobilenumber.Text = "" Then
lblnotifmobile.caption = "Please provide Mobile number!"
txtmobilenumber.SetFocus

ElseIf txtsubsname.Text = "" Then
lblnotifname.caption = "Please provide Subscriber's Name!"
txtsubsname.SetFocus

ElseIf cmbcalltype.Text = "" Then
lblcalltype.caption = "Please provide Call Type!"
cmbcalltype.SetFocus

ElseIf cmbconcerntype.Text = "" Then
lblconcerntype.caption = "Please provide Concern Type!"
cmbconcerntype.SetFocus


ElseIf MsgBox("Are you sure you want to add this TCD?", vbQuestion + vbYesNo, "TCD") = vbYes Then

Dim DatabaseContext As Object
   Dim DataSource As Object
   Dim Connection As Object
   Dim InteractionHandler as Object
   Dim Statement As Object
   Dim ResultSet As Object
   DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
   DataSource = DatabaseContext.getByName("TCD")
     InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
     Connection = DataSource.ConnectWithCompletion(InteractionHandler)
   Statement = Connection.createStatement()
   'Resultset =
   Statement.executeQuery("INSERT INTO tcd VALUES ('" & txtsubsname.Text & "','" & txtmobilenumber.Text & "', '" & cmbcalltype.Text & "', '" & cmbconcerntype.Text & "', '" & newloginform.Label3.Caption & "', '" & txtverbatim.Text & "', '" & lbldate.Caption & "', '" & newloginform.Label2.Caption & "')")
   '("Select * from LoginDbase WHERE EmployeeID = '" & txtusername.Text & "' and Password = '" & txtpassword.Text & "' ")   
   connection.close

MsgBox "TCD Sucessfully Saved!", vbInformation, "Top Call Driver"

txtcompile.Text = "ACD: " & txtacd.Text & Chr(13) & "Mobile Number: " & txtmobilenumber.Text & Chr(13) & "Subscribers Name: " & txtsubsname.Text & Chr(13) & "Call Type: " & cmbcalltype.Text & Chr(13) & "Concern Type: " & cmbconcerntype.Text & Chr(13) & "Customer Concern/Verbatim: " & txtverbatim.Text

   
txtsubsname.Text = ""
txtmobilenumber.Text = ""
cmbcalltype.Text = ""
cmbconcerntype.Text = ""
txtacd.Text = ""
txtverbatim.Text = ""


Else
End If
End Sub

Private Sub cmbconcerntype_Change()
   If not IsEmpty(cmbconcerntype.text) then
      lblconcerntype.caption = ""
   End If
End Sub


Private Sub cmbcalltype_Change()
   If not IsEmpty(cmbcalltype.text) then
      lblcalltype.caption = ""
   End If
Dim message


If cmbcalltype.Text = "RECONTRACTING AVAILMENT" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "HANDSET"
      .AddItem "SIM ONLY"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "RECONTRACTING INQUIRY" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "QUALIFIED - UNDECIDED"
      .AddItem "QUALIFIED - PREFERRED UNIT OOS"
      .AddItem "NOT QUALIFIED - WITHIN CONTRACT"
      .AddItem "NOT QUALIFIED - WITH OB/HOB"
      .AddItem "NOT QUALIFIED - INSUFFICIENT CL"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "OTHERS" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "DROPPED CALL"
      .AddItem "PRANK CALL"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "ACCOUNT RELATED" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "PLAN MODIFICATION"
      .AddItem "LUP INQUIRY"
      .AddItem "CHANGE SIM"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "BILLING RELATED" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "BILL INQUIRY"
      .AddItem "BILL ADJUSTMENT"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "AFTERSALES/FOLLOW UP" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "RF REQUEST"
      .AddItem "FOLLOW-UP WITHIN TAT DELIVERY"
      .AddItem "FOLLOW-UP BEYOND TAT DELIVERY"
      .AddItem "FOLLOW-UP WITHIN TAT PUP"
      .AddItem "FOLLOW-UP BEYOND TAT PUP"
      .AddItem "AGP COMPLAINT"
      .AddItem "CANCELATION OF ORDER"
      .AddItem "CASE CLOSURE FOR ACTIVATION"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "TRANSFER" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "BILLING RELATED"
      .AddItem "ACCOUNT MODIFICATION"
      .AddItem "PERMANENT DISCONNECTION"
      .AddItem "TECHNICAL CONCERNS WIRELESS"
      .AddItem "RECONNECTION"
      .AddItem "SALES"
      .AddItem "BROADBAND CONCERNS"
      .AddItem "BUSINESS CONCERNS"
   End With
   cmbconcerntype.Text = ""

ElseIf cmbcalltype.Text = "REWARDS RELATED" Then
   cmbconcerntype.Clear
   With cmbconcerntype
      .AddItem "REWARDS POINTS"
   End With
   cmbconcerntype.Text = ""


Else
End If
End Sub


Private Sub CommandButton1_Click()
   Dim myApp As String
   myApp = Shell("Notepad", vbNormalFocus)
   'SendKeys "ARDD"
End Sub


''''DONE
Private Sub UserForm_Activate()

   lbldate.Caption = Format(Now, "MM/dd/yyyy")
   lblagentname.Caption = newloginform.Label2.Caption
   txtacd.Text = ""
   txtsubsname.Text = ""
   txtmobilenumber.Text = ""
   cmbcalltype.Text = ""
   cmbconcerntype.Text = ""
'   txtmobilenumber.Text = "9*********"
   txtacd.SetFocus
   lblnotifok.caption = ""
   
      
   cmbcalltype.Clear
   With cmbcalltype
      .AddItem "RECONTRACTING AVAILMENT"
      .AddItem "RECONTRACTING INQUIRY"
      .AddItem "OTHERS"
      .AddItem "ACCOUNT RELATED"
      .AddItem "BILLING RELATED"
      .AddItem "AFTERSALES/FOLLOW UP"
      .AddItem "TRANSFER"
      .AddItem "REWARDS RELATED"
   End With



End Sub



'''''DONE''''

Private Sub txtacd_focusout()
   If txtacd.text = "" then
      lblnotifacd.caption = "Please provide ACD!"
   ElseIf not isnumeric(txtacd.text) then
      lblnotifacd.caption = "Only Numbers are accepted for ACD!"
      'txtacd.SetFocus
   ElseIf Not isempty(txtacd.text) then
      lblnotifacd.caption = ""
   End If
End Sub
'Private Sub txtacd_KeyPressed(e As System.Windows.Forms.KeyEventArgs)
' Dim event as Object
' event = com.sun.star.awt.Key
' Select Case e.KeyCode
'    Case event.NUM0, event.NUM1, event.NUM2, event.NUM3, event.NUM4, event.NUM5, event.NUM6, event.NUM7, event.NUM8, event.NUM9
'    Case event.BACKSPACE, event.SPACE, event.TAB, event.DELETE,   event.DOWN,   event.UP, event.LEFT, event.RIGHT
'    Case Else
'       e.KeyCode = 0
'       Beep
'       MsgBox "Only Numbers are accepted!", vbCritical, "Message"
' End Select
'End Sub
Private Sub txtmobilenumber_focusout()
   If txtmobilenumber.text = "" then
      lblnotifmobile.caption = "Please provide Mobile number!"
   ElseIf Not isempty(txtmobilenumber.text) then
      lblnotifmobile.caption = ""
         If not isnumeric(txtmobilenumber.text) then
         lblnotifmobile.caption = "Only Numbers are accepted for Mobile Number!"
            ElseIf len(txtmobilenumber.text)  <> 10 then
            'Msgbox "Invalid mobile number format." & vbNewLine & "ex.9*********", 48, "Message"
            lblnotifmobile.caption = "Invalid mobile number format."
            'txtmobilenumber.Setfocus
      End if
   End if
End Sub

Private Sub txtsubsname_focusout()
If txtsubsname.text = "" then
   lblnotifname.caption = "Please provide Subscriber's Name!"
Else
   lblnotifname.caption = ""
End If
   
End Sub




Re: Macro is not running when my file is newly open

PostPosted: Thu May 10, 2018 6:49 am
by Zizi64
i tried to attach the file but it was too big.

Use a free file sharing service, like the Google Drive or other. In this case you need share the link only in this forum.

Re: Macro is not running when my file is newly open

PostPosted: Wed May 16, 2018 8:31 pm
by KarenRogers
I have the same problem in Open Office writer. I record the macro, save it, it works fine until I close Open Office and go back in, then the macro is gone. I am saving under My Macros.

Re: Macro is not running when my file is newly open

PostPosted: Wed May 16, 2018 8:35 pm
by RoryOF
In which format do you Save? OO's native ODF formats are best.

Re: Macro is not running when my file is newly open

PostPosted: Wed May 16, 2018 8:51 pm
by Zizi64
I am saving under My Macros.

OK - but which Library and which Module you saving to?

Use the Standard Library and Module 1


If you want to save your macros into the file, then use the "Filename" - Standard library - Module 1. You MUST use the native ODF fileformats in this case.

Re: Macro is not running when my file is newly open

PostPosted: Wed May 16, 2018 9:01 pm
by KarenRogers
yes, I am saving to the standard library and Module 1. I read an article about trying to create a new library and new module but I doubt that would help. Thanks for trying.

Re: Macro is not running when my file is newly open

PostPosted: Wed May 16, 2018 9:07 pm
by Zizi64
yes, I am saving to the standard library and Module 1.

Did you meant:

MyMacros - Standard library - Module 1

or

"YourFilename"- Standard library - Module 1

????


Are you using ODF filetypes?

Re: Macro is not running when my file is newly open

PostPosted: Wed May 16, 2018 9:17 pm
by KarenRogers
My Macros, standard library, module 1. I rewrote them (they were easy) and I will now exit Open Office and see if it saved them.