×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Attachmate msg box not working In VB code

Attachmate msg box not working In VB code

Attachmate msg box not working In VB code

(OP)
Hi I've developed a macro to check on attachmate a list of payments collected from excell, the macro works in the respect that it opens the invoice and shows if payment has or hasn't been collected and will copy all the required info to and from attachmate and excell.
However I want it to bring up a msg box asking to proceed or cancel as if payment is showing click ok and macro continues if payment not there can click cancel and macro will stop.

Now the msg box part of the macro works in attachmatess .ebm but
isn't working in VB I would like to get Vb to recognise this part of code any help would be great.


    Dim Excel As Object
    Dim Session As Object
    Dim MyScreen As Object

'--------------------------------------------------------------------------------
    
'Get Invoice number from Excel.
      
        ActiveCell.Offset(1, 0).Select
        Application.Goto Range("A" & ActiveCell.Row), True
        ActiveCell.Select
        ActiveCell.Copy
            
'--------------------------------------------------------------------------------

'Load Invoice.
        
        AppActivate "NBBS-USER - EXTRA! X-TREME"
        Sess1.Screen.SendKeys ("<Find>NBABA<Ctrl+M>")
        Sess1.Screen.SendKeys ("NB50")
        Sess1.Screen.Paste
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Sess1.Screen.MoveTo 1, 15, 1
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Sess1.Screen.SendKeys ("D<Ctrl+M>")
        
        Begin Dialog UserDialog 125, 34, "Do You Wish to Proceed?"

      ButtonGroup .ButtonGroup1
      OKButton 5, 10, 54, 16
      CancelButton 62, 10, 54, 16
   End Dialog
   Dim mydialog As UserDialog
   On Error Resume Next

   Dialog mydialog
   If Err = 102 Then Stop
'--------------------------------------------------------------------------------
'Get Date Clear
        Set MyScreen = Sess1.Screen
        Set MyArea = MyScreen.Area(9, 3, 9, 10)
        MyArea.Select
        Sess1.Screen.Copy
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
'--------------------------------------------------------------------------------
 'Put Date clear into the MS Excel Spread Sheet
       
         Application.Goto Range("I" & ActiveCell.Row), True
         ActiveCell.PasteSpecial
'--------------------------------------------------------------------------------
'Get Auth Code
        
        Application.Goto Range("G" & ActiveCell.Row), True
        ActiveCell.Copy
'--------------------------------------------------------------------------------
'Put note and Auth Code In Billing

        Answer = MsgBox("Proceed?", _
        vbOKCancel, "My Title")
        If Answer = vbCancel Then Exit Sub ' the macro ends if the user selects the CANCEL-button

        Sess1.Screen.SendKeys ("<Left>1<Ctrl+M>")
        g_HostSettleTime = 0        ' milliseconds
        Sess1.Screen.SendKeys ("INDAY PAYMENT TAKEN EPDQ - ")
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Sess1.Screen.Paste
        
'--------------------------------------------------------------------------------
'Get Date Taken
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Set MyScreen = Sess1.Screen
        Set MyArea = MyScreen.Area(4, 10, 4, 27)
        MyArea.Select
        Sess1.Screen.Copy
      
'--------------------------------------------------------------------------------
 'Put Date Taken In Billing
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Application.Goto Range("H" & ActiveCell.Row), True
        ActiveCell.Copy
        Sess1.Screen.MoveTo 18, 56, 1
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Sess1.Screen.Paste
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
        Sess1.Screen.SendKeys ("AC")
        Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
    
End Sub

RE: Attachmate msg box not working In VB code

it appears that you are coding this in vba. your code is very interesting.
what is the purpose of the dialog that you are evoking from attachmate?

Quote:

However I want it to bring up a msg box asking to proceed or cancel as if payment is showing click ok and macro continues if payment not there can click cancel and macro will stop.

is there a need for a prompt to continue? can't you code it to stop when there is no payment showing instead?

by the way, just an observation:
your code

CODE

'Get Date Clear        
Set MyScreen = Sess1.Screen        
Set MyArea = MyScreen.Area(9, 3, 9, 10)        MyArea.Select        
Sess1.Screen.Copy        
Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
'----------------------------------------------------
'Put Date clear into the MS Excel Spread Sheet                Application.Goto Range("I" & ActiveCell.Row), True         ActiveCell.PasteSpecial
can be written this way instead

CODE

extradat = sess1.screen.getstring(9,3,8)
range("I" & ActiveCell.Row) = extradat
'---or---
range("I" & ActiveCell.Row)=sess1.screen.getstring(9,3,8)

the same holds true when passing the data from excel to extra
your code

CODE

'Put Date Taken In Billing        
Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
Application.Goto Range("H" & ActiveCell.Row), True
ActiveCell.Copy
Sess1.Screen.MoveTo 18, 56, 1
Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
Sess1.Screen.Paste

Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
Sess1.Screen.SendKeys ("AC")
Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
can be written

CODE

exceldat = Range("H" & ActiveCell.Row)
sess1.screen.putstring exceldat, 18,56

RE: Attachmate msg box not working In VB code

(OP)
you are correct I am coding this in Excel the purpose is to load the invoice in attachmate and see if the payment has been made if it has the code is to continue and put all spread sheet info in atatchmate if not I need it to stop.

Thank you for your suggestions on making the code simpler i will implement them.

I hadn't actually considered your suggestion of having it actually stop if payment not showing what would you suggest as best method of doing this.

Thanks

RE: Attachmate msg box not working In VB code

when you load the invoice, what indicates the invoice has been paid?  

RE: Attachmate msg box not working In VB code

(OP)
Hi I have uploaded a screen shot to make it clearer I have had to remove the personal info due to dpa but as you can see the macro loads the invoice then it will show balance as 0.00 in top right and then it will show history i.e date invoice created along with amount then would show next of next action and next action which would either be cash and amount paid or a reminder.
 

RE: Attachmate msg box not working In VB code

A message box written in Extra! Basic will not work in VBA.  You'll need to rewrite your code.

This example is straight from the VBA help, it should get you started:

MsgBox Function Example
This example uses the MsgBox function to display a critical-error message in a dialog box with Yes and No buttons. The No button is specified as the default response. The value returned by the MsgBox function depends on the button chosen by the user. This example assumes that DEMO.HLP is a Help file that contains a topic with a Help context number equal to 1000.


CODE

Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to continue ?"    ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2    ' Define buttons.
Title = "MsgBox Demonstration"    ' Define title.
Help = "DEMO.HLP"    ' Define Help file.
Ctxt = 1000    ' Define topic
        ' context.
        ' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then    ' User chose Yes.
    MyString = "Yes"    ' Perform some action.
Else    ' User chose No.
    MyString = "No"    ' Perform some action.
End If

 

RE: Attachmate msg box not working In VB code

rob7785,

not knowing the exact coordinates, use this as a guideline:

CODE

if sess.getstring (1,2,4) = "0.00" then exit sub

or if you rather have a prompt

CODE

if sess.getstring(1,2,4) = "0.00" then

'add code from rgm33

end if

 

RE: Attachmate msg box not working In VB code

(OP)
Thanks vzachin I thought it would be something to do witht he If command wasn't quite sure how to go about it but makes perfect sense so thanks.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close