Jump to content

Error -1


Recommended Posts

This is an obvious 'Object' error.

The object was not created correctly and you tried to use it and it failed.

you can...

#1

Use IsObject($o_Object) to test that the object has been created before you use it

#2

Use an "object error register" there are a few examples of these in the help files and there is one specifically for Internet Explorer objects under IE.au3.

Hope that helps

8)

NEWHeader1.png

Link to comment
Share on other sites

If you want to get help, please post your code.

Here is the code:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Statement Printer", 293, 255, 970, 252)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1_1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1_1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1_1Restore")
$Dateinput = GUICtrlCreateInput("", 101, 13, 169, 21)
GUICtrlSetOnEvent(-1, "DateinputChange")
$Custcodeinput = GUICtrlCreateInput("", 101, 53, 169, 21)
GUICtrlSetOnEvent(-1, "CustcodeinputChange")
$Combo = GUICtrlCreateCombo("", 101, 101, 169, 25)
GUICtrlSetData(-1, "PMI|DP|EP|KP|PR|SP")
GUICtrlSetOnEvent(-1, "ComboChange")
$PDF = GUICtrlCreateButton("PDF", 13, 149, 81, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "PDFClick")
$Print = GUICtrlCreateButton("Print", 103, 149, 81, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "PrintClick")
$Email = GUICtrlCreateButton("Email", 193, 149, 81, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "EmailClick")
$PDFPRINT = GUICtrlCreateButton("PDF + Print", 13, 199, 129, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "PDFPRINTClick")
$PDFEMAIL = GUICtrlCreateButton("PDF + Email", 150, 199, 129, 41, $WS_GROUP)
GUICtrlSetOnEvent(-1, "PDFEMAILClick")
$Label3 = GUICtrlCreateLabel("Company", 12, 101, 48, 17)
GUICtrlSetOnEvent(-1, "Label3Click")
$Label2 = GUICtrlCreateLabel("Cust Code", 13, 57, 53, 17)
GUICtrlSetOnEvent(-1, "Label2Click")
$Label1 = GUICtrlCreateLabel("Date", 13, 13, 27, 17)
GUICtrlSetOnEvent(-1, "Label1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    Sleep(100)
WEnd



Func ComboChange()

EndFunc   ;==>ComboChange
Func CustcodeinputChange()

EndFunc   ;==>CustcodeinputChange
Func DateinputChange()

EndFunc   ;==>DateinputChange
Func EmailClick()

EndFunc   ;==>EmailClick
Func Form1_1Close()
    WinClose("PDFTK Builder")
    Exit
EndFunc   ;==>Form1_1Close
Func Form1_1Maximize()

EndFunc   ;==>Form1_1Maximize
Func Form1_1Minimize()

EndFunc   ;==>Form1_1Minimize
Func Form1_1Restore()

EndFunc   ;==>Form1_1Restore
Func Label1Click()

EndFunc   ;==>Label1Click
Func Label2Click()

EndFunc   ;==>Label2Click
Func Label3Click()

EndFunc   ;==>Label3Click
Func PDFClick()
    Call("Debtorstatementscreen")
    Call("convertopdf")

EndFunc   ;==>PDFClick
Func PDFEMAILClick()
    Opt("wintitlematchmode", 2)
    Call("Debtorstatementscreen")
    Call("convertopdf")
    Call("pdftkbuilder")
call("emailme")




EndFunc   ;==>PDFEMAILClick
Func PDFPRINTClick()
    Opt("wintitlematchmode", 2)
    Call("Debtorstatementscreen")
    Call("convertopdf")
    Call("pdftkbuilder")
    Call("printme")



EndFunc   ;==>PDFPRINTClick
Func PrintClick()
    Opt("wintitlematchmode", 2)
    Call("Debtorstatementscreen")

    WinWaitActive("Preview")
    MouseClick("left", 46, 91, 1, 0)

EndFunc   ;==>PrintClick
Func Debtorstatementscreen()
    Opt("wintitlematchmode", 2)
    $dateinputread = GUICtrlRead($Dateinput)
    $custcodeinputread = GUICtrlRead($Custcodeinput)
    $comboread = GUICtrlRead($Combo)
    ;--------------------
    WinActivate("Quote")
    WinWaitActive("Quote")
    Sleep(100)

    MouseClick("left", 687, 421, 1, 0)
    Sleep(100)

    Send("{home}")
    Sleep(100)
    Send("+{End}")
    Sleep(100)
    Send("{bs 20}")
    Sleep(100)

    Send($dateinputread)
    Send("{tab}")
    Send($custcodeinputread)
    Send("{tab 2}")
    Send($custcodeinputread)
    Send("{tab}")
    Sleep(100)
    ControlClick("Quote", "", "[CLASS:ClaButton_01000000H; INSTANCE:6]", "left", 1)
    ;--------------------------
EndFunc   ;==>Debtorstatementscreen
Func convertopdf()
    Opt("wintitlematchmode", 2)

    ;----------Begin PDF CLick------------------;
    WinWaitActive("Preview")
    Sleep(100)
    MouseClick("left", 408, 91, 1, 0)
    Sleep(200)
    MouseClick("left", 120, 90, 1, 0)
    ;----------End PDF CLick------------------;
EndFunc   ;==>convertopdf

Func pdftkbuilder()

    ;----------declaring variables and running pdftk------------------------;

    ShellExecute("C:\Program Files\PDFTK Builder\PDFTKBuilder.exe")
    WinWait("PDFTK Builder")

    $dateinputread = GUICtrlRead($Dateinput)
    $custcodeinputread = GUICtrlRead($Custcodeinput)
    $comboread = GUICtrlRead($Combo)
    $stampfile = "c:\pdf\" & $comboread & "-statement.pdf"

;----------Choosing between the stamp files------------------------;


If $comboread = "XYZ" Then
        $savefile = "c:\Statements\[XYZ corporation] Statement for " & $custcodeinputread & ".pdf"

    ElseIf $comboread = "DP" Then
        $savefile = "c:\Statements\[1234567 Printing] Statement for " & $custcodeinputread & ".pdf"

    ElseIf $comboread = "PR" Then
        $savefile = "c:\Statements\[12345 Printing] Statement for " & $custcodeinputread & ".pdf"

    ElseIf $comboread = "KP" Then
        $savefile = "c:\Statements\[123456 Printing] Statement for " & $custcodeinputread & ".pdf"

    ElseIf $comboread = "SP" Then
        $savefile = "c:\Statements\[1234 Printing] Statement for " & $custcodeinputread & ".pdf"

    ElseIf $comboread = "EP" Then
        $savefile = "c:\Statements\[123 Printing] Statement for " & $custcodeinputread & ".pdf"

    EndIf

    Sleep(300)

    ;----------pdftk operations------------------------;

    ControlClick("PDFTK Builder", "", "TPageControl1", "left", 3, 173, 12)

    ControlClick("PDFTK Builder", "S&ource PDF Document ...", "TButton4", "left", 1, 95, 14)
    WinWait("Select PDF files ...")
    ControlSend("Select PDF files ...", "", "Edit1", "c:\report.pdf {enter}", 0)

    Sleep(50)

    WinWaitClose("Select PDF files ...")

    Sleep(100)

    ;----------definining stamp file in pdftk------------------------;

    ControlClick("PDFTK Builder", "Back&ground or Stamp PDF Page ...", "TButton3", "left", 1, 90, 14)
    WinWait("Select PDF files ...")
    ControlSend("Select PDF files ...", "", "Edit1", $stampfile & "{enter}", 0)

    WinWaitClose("Select PDF files ...")
    Sleep(100)

    ControlClick("PDFTK Builder", "Sta&mp", "TRadioButton1", "left", 1, 7, 7)

    ControlClick("PDFTK Builder", "Add Backgro&und or Stamp to First Page Only", "TCheckBox10", "left", 1, 7, 7)

    ControlClick("PDFTK Builder", "Save &As", "TButton2", "left", 1, 44, 12)

    Sleep(100)
    ;---------- Saving the file ------------------------;
WinWait("Save As")


    ControlSend("Save As", "", "Edit1", $savefile)

    Sleep(50)

    ControlSend("Save As", "", "Edit1", "{home}", 0)
    ControlSend("Save As", "", "Edit1", "{Right}", 0)
    ControlSend("Save As", "", "Edit1", "{Del 2}", 0)
    ControlSend("Save As", "", "Edit1", ":\", 1)
    ControlSend("Save As", "", "Edit1", "{enter}", 0)

    WinWaitClose("Save As")

Sleep(200)
;---------- close pdftk ------------------------;

    ControlClick("PDFTK Builder", "E&xit", "TButton1", "left", 1, 44, 12)

Sleep(50)


EndFunc   ;==>pdftkbuilder

Func Printme()
    ;----------declaring variables-----------------------;


    $dateinputread = GUICtrlRead($Dateinput)
    $custcodeinputread = GUICtrlRead($Custcodeinput)
    $comboread = GUICtrlRead($Combo)

    ;----------Printing the file-----------------------;

    If $comboread = "XYZ" Then
        $ourfile = "c:\Statements\[XYZ corporation] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "DP" Then
        $ourfile = "c:\Statements\[1234567 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "PR" Then
        $ourfile = "c:\Statements\[12345 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "KP" Then
        $ourfile = "c:\Statements\[123456 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "SP" Then
        $ourfile = "c:\Statements\[1234 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "EP" Then
        $ourfile = "c:\Statements\[123 Printing] Statement for " & $custcodeinputread & ".pdf"
    EndIf

    ShellExecute($ourfile, "/print showui:yes", "", "print")


EndFunc   ;==>Printme
func emailme()

;~ ;----------declaring variables-----------------------;

$dateinputread = GUICtrlRead($Dateinput)
    $custcodeinputread = GUICtrlRead($Custcodeinput)
    $comboread = GUICtrlRead($Combo)
opt("wintitlematchmode",2)

;~  ;----------Selecting the Correct file-----------------------;

    If $comboread = "XYZ" Then
        $ourfile = "c:\Statements\[XYZ corporation] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "DP" Then
        $ourfile = "c:\Statements\[1234567 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "PR" Then
    $ourfile = "c:\Statements\[12345 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "KP" Then
        $ourfile = "c:\Statements\[123456 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "SP" Then
        $ourfile = "c:\Statements\[1234 Printing] Statement for " & $custcodeinputread & ".pdf"
    ElseIf $comboread = "EP" Then
        $ourfile = "c:\Statements\[123 Printing] Statement for " & $custcodeinputread & ".pdf"
    EndIf

    ;ShellExecute("C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE", "/a " & $ourfile)
;~ -------------creating the email-------------------
Const $olByValue = 1
    Local $olMailItem = 0
    Local $olFormatRichText = 3
    Local $olImportanceLow = 0
    Local $olImportanceNormal = 1
    Local $olImportanceHigh = 2

    $oOApp = ObjCreate("Outlook.Application.12")
    $oOMail = $oOApp.CreateItem($olMailItem)

    With $oOMail
        .To =("")
        .Subject = $ourfile
        .BodyFormat = $olFormatRichText
        .Importance = $olImportanceNormal
        .Body = ""
        .Attachments.add($ourfile)
        .Display
    EndWith
;~ '---------------Modifying the Subject Line---------------------;



WinWait("Message")
;~ Sleep(300)
;~ ControlClick($ourfile & " - Message (HTML) ","","NetUIHWND1","left",1,553,93)

;~ WinWait("Insert File")
;~ ControlSend("Insert File","","RichEdit20W2",$ourfile)
;~ ControlSend("Insert File","","RichEdit20W2","{enter}",0)
;~ WinWaitClose("Insert File")
Sleep(200)
ControlSend($ourfile & " - Message","","RichEdit20WPT5","{Home}",0)
ControlSend($ourfile & " - Message","","RichEdit20WPT5","{Del 14}",0)
ControlSend($ourfile & " - Message","","RichEdit20WPT5","{End}",0)
ControlSend($ourfile & " - Message","","RichEdit20WPT5","{BS 4}",0)
;ControlSend($ourfile & " - Message","","RichEdit20WPT5","{tab 5}",0)

Sleep(100)
;ControlClick($ourfile & " - Message","[CLASS:_WwG; INSTANCE:1]","left",1,117,87)
;ControlSend($ourfile & " - Message","","[CLASS:_WwG; INSTANCE:1]","Please find your statement attached. Please notify us if you have any problems downloading the attachment.",1)
;ControlSend($ourfile & " - Message","","[CLASS:_WwG; INSTANCE:1]","{enter 5}",0)


    EndFunc


Func CreateMailItem()

EndFunc   ;==>CreateMailItem

Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...