Jump to content
Sign in to follow this  

[SOLVED] Use button to execute one Excel file

Recommended Posts

Hello all. Its been quite some time I don't use AutoIT.

Well, only the button "Open" and "Fechar" are working, my main problem now is, I am not been able to "execute/open" a Excel file that already exists.

I can select it, but can't make it to open like double clicking.

Here's my code, hope that some one can help me.

Thanks in advance, mini.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Excel.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Dialog", 368, 203)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Procurar = GUICtrlCreateButton("&Procurar", 285, 11, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Procurar")
$Adicionar = GUICtrlCreateButton("&Adicionar", 285, 44, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Adicionar")
$Fechar = GUICtrlCreateButton("&Fechar", 285, 76, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Fechar")
$Open = GUICtrlCreateButton("&Open", 285, 105, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "_Open")
$Edit1 = GUICtrlCreateEdit("", 8, 8, 273, 185)
GUICtrlSetData(-1, "Edit1")
GUICtrlSetOnEvent(-1, "Edit1Change")
$Input1 = GUICtrlCreateInput("Modelo", 288, 136, 73, 21)
GUICtrlSetOnEvent(-1, "Input1Change")
$DB_Dir = GUICtrlCreateInput("", 288, 136, 1, 1)
GUICtrlSetOnEvent(-1, "Input1Change")
#EndRegion ### END Koda GUI section ###

Dim $File

While 1

Func Procurar()

EndFunc   ;==>Procurar
Func Adicionar()

EndFunc   ;==>Adicionar
Func _Open()
;~  $File = FileOpenDialog("Abrir ficheiro DB", "", "(*.xls;*.xlsx;*.xlsm)")
    $File = FileOpenDialog(@ScriptDir & "\", "", "(*.xls;*.xlsx;*.xlsm)")

    If FileExists($File) Then
        GUICtrlSetData($Input1, $File)
;~  $File = FileOpenDialog("Abrir ficheiro DB", "", "Ficheiros Excell(*.xls;*.xlsx;*.xlsm)")
;~  If FileExists($File) Then
;~      GUICtrlSetData($Input1, $File)
;~      Sleep (5000)
;~      _Abrir()
;~  EndIf
EndFunc   ;==>_Open
;~ Func _Abrir()
;~  run("excel.exe")
;~ EndFunc   ;==>_Abrir

Func Fechar()
    $answer = MsgBox(36, "Aviso", "Quer mesmo sair?", 8)
    If $answer = 6 Then
EndFunc   ;==>Fechar
Func Edit1Change()

EndFunc   ;==>Edit1Change
Func Form1Close()
    $answer = MsgBox(36, "Aviso", "Quer mesmo sair?", 8)
    If $answer = 6 Then
EndFunc   ;==>Form1Close
Func Form1Maximize()

EndFunc   ;==>Form1Maximize
Func Form1Minimize()

EndFunc   ;==>Form1Minimize
Func Form1Restore()

EndFunc   ;==>Form1Restore
Func Input1Change()

EndFunc   ;==>Input1Change
Edited by mini

Share this post

Link to post
Share on other sites

$File = FileOpenDialog(@ScriptDir & "\", "", "(*.xls;*.xlsx;*.xlsm)",1)
    If Not @error Then
        GUICtrlSetData($Input1, $File)
;~      ShellExecute(GUICtrlRead($Input1))

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.


Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...