Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachmate msg box not working In VB code 1

Status
Not open for further replies.

rob7785

Technical User
Aug 4, 2011
11
GB
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
 
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?

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)
[blue]Application.Goto Range("H" & ActiveCell.Row), True
ActiveCell.Copy
Sess1.Screen.MoveTo 18, 56, 1
Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
Sess1.Screen.Paste[/blue]
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
 
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
 
when you load the invoice, what indicates the invoice has been paid?
 
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.
 
 http://www.mediafire.com/?qsc2fxy4bxwey3m
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

 
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

 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top