Jump to content

Excel not opening


Recommended Posts

Hi everyone, at work im using Windows 7 and using Microsort Office 2010. when i execute my program at home (vista and office 2003) it runs perfectly but when i run it at work it comes up with the error

"C:\Users\Sendean 2\Desktop\Project\GUI.au3 (312) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:

Local $oExcel = _ExcelBookNew(0)"

I obviously understand this is because of the loop constantly going round and round but it never opens excel.

i made a script with a single case of it opening and waiting for excel to open and nothing happens. is it compatible with windows office 2010?

Iv added my entire code. its for data entry on to an excel document, i realise im not a pro scripter as i taught myself autoit and haven't explorered it thoroughly so dont laugh at the bad scripting.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=data entry.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Excel.au3>

$directory  = @DesktopDir&"\project\"
$ini = $directory&"ini.ini"
$inilist = iniread($ini,"logincombolist","names","")
$inisummarycombo = iniread($ini,"summarycombolist","list","Proceeded prepaid|Proceeded not paid|RUR")
$firstname = ""
$oldthisdate=""
$oldthistime=""
$textfile=""
$datalog=""
global $time,$ticketinput,$summarycombo,$descriptioninput,$inotifiedinput,$totalexcinput,$totalplusinput
Func login()
guidelete()
#Region ### START Koda GUI section ### Form=C:\Users\JoBo&Louisa\Desktop\Project\loginform.kxf
$LOGINGUI = GUICreate("Log in", 323, 385, -1, -1)
GUISetBkColor(0xA6CAF0)
$Firstnamecombo = GUICtrlCreateCombo("", 89, 182, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUICtrlSetData(-1,$inilist ,"Name")
$Loginbutton = GUICtrlCreateLabel("Log in", 115, 280, 94, 65, $WS_BORDER)
GUICtrlSetFont(-1, 40, 400, 0, "Gloucester MT Extra Condensed")
GUICtrlSetCursor (-1, 0)
$firstnamelabel = GUICtrlCreateLabel("First name", 83, 32, 157, 58)
GUICtrlSetFont(-1, 40, 400, 0, "Gloucester MT Extra Condensed")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   GUISetState(@SW_MINIMIZE)
  Case $Loginbutton
   $firstname = guictrlread($Firstnamecombo)
   $firstnamecheck = iniread($ini,$firstname,"login",0)
   if $firstnamecheck >= 1 Then
    iniwrite($ini,$firstname,"login",$firstnamecheck+1)
    $oldthistime = iniread($ini,$firstname,"thistime",@hour&":"&@MIN)
    iniwrite($ini,$firstname,"lasttime",$oldthistime)
    iniwrite($ini,$firstname,"thistime",@hour&":"&@MIN)
    $oldthisdate = iniread($ini,$firstname,"thisdate",@year&"."&@mon&"."&@mday)
    iniwrite($ini,$firstname,"lastdate",$oldthisdate)
    iniwrite($ini,$firstname,"thisdate",@year&"."&@mon&"."&@mday)
    startlog()
   Else
    if $firstname = "" Then
    else
     if $firstname = "admin1914" Then
      $adminuser = 1
      startadminlog()
     Else
      if $firstname = "refresh" Then
       $inilist = iniread($ini,"logincombolist","names","")
       guictrlsetdata($Firstnamecombo,"")
       guictrlsetdata($Firstnamecombo,$inilist)
      else
       msgbox(0,"Error","Contact your computer administrator to set up a new user account")
      EndIf
     EndIf
    EndIf
   EndIf
EndSwitch
WEnd
EndFunc
Func Startlog()
guidelete()
#Region ### START Koda GUI section ### Form=
$Dataentry = GUICreate($firstname&"'s data entry", 324, 561, -1, -1)
GUISetBkColor(0xA6CAF0)
$summarylabel = GUICtrlCreateLabel("Brief summary", 53, 125, 83, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$summarycombo = GUICtrlCreateCombo("", 13, 153, 163, 25,BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $inisummarycombo)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$timelabel = GUICtrlCreateLabel("Time", 233, 125, 31, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$time = GUICtrlCreateCombo("", 196, 153, 105, 31, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "9:00-10:00|10:00-11:00|11:00-12:00|12:00-13:00|13:00-14:00|14:00-15:00|15:00-16:00|16:00-17:00|17:00-18:00")
GUICtrlSetFont(-1, 16, 400, 0, "Gloucester MT Extra Condensed")
$ticketlabel = GUICtrlCreateLabel("Ticket number", 50, 197, 83, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$ticketinput = GUICtrlCreateInput("", 13, 226, 163, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER), $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUICtrlSetLimit (-1, 5)
$totalexclabel = GUICtrlCreateLabel("Total EXC VAT", 203, 195, 87, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$totalexcinput = GUICtrlCreateInput("", 196, 223, 105, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$totalpluslabel = GUICtrlCreateLabel("Total Paid", 217, 266, 59, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$totalplusinput = GUICtrlCreateInput("", 196, 295, 105, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$inotifiedllabel = GUICtrlCreateLabel("I notified _ by _", 50, 266, 84, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$inotifiedinput = GUICtrlCreateInput("", 13, 295, 163, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$descriptionlabel = GUICtrlCreateLabel("Description", 128, 336, 67, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$descriptioninput = GUICtrlCreateEdit("", 13, 368, 297, 145,$ES_WANTRETURN)
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUICtrlSetTip(-1, "I.E Definately went ahead with full service")
$enterbutton = GUICtrlCreateLabel("Enter data", 228, 518, 82, 36, $WS_BORDER)
GUICtrlSetFont(-1, 20, 400, 0, "Gloucester MT Extra Condensed")
$loggedinlabel = GUICtrlCreateLabel("Logged in: "&$firstname, 13, 8, 120, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$logoutbutton = GUICtrlCreateLabel("Log out", 272, 8, 46, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$logintimelabel = GUICtrlCreateLabel("Log in time: "&@hour&":"&@min, 13, 40, 150, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$previouslogintimelabel = GUICtrlCreateLabel("Previous Log in: "&$oldthistime&" - "&$oldthisdate, 13, 72, 250, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$Clearbutton = GUICtrlCreateLabel("Clear", 13, 527, 32, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$openbutton = GUICtrlCreateLabel("Open", 279, 38, 33, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$creatmessagebutton = GUICtrlCreateLabel("Create Message", 62, 526, 88, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   GUISetState(@SW_MINIMIZE)
  case $creatmessagebutton
   $datasummary=guictrlread($summarycombo)
   $dataedit=guictrlread($descriptioninput)
   $datanotified=GUICtrlRead($inotifiedinput)
   $datatotalexc=guictrlread($totalexcinput)
   $dataprepaid=guictrlread($totalplusinput)
   $copy = ""
   if not $datasummary = "" Then
    $copy = $datasummary
   EndIf
   if not $datatotalexc = "" Then
    if StringInStr ($datatotalexc,"£") Then
     $copy = $copy&" - "&$datatotalexc&"+VAT"
    Else
     $copy = $copy&" - £"&$datatotalexc&"+VAT"
    EndIf
   EndIf
   if not $dataprepaid = "" Then
    if StringInStr ($dataprepaid,"£") Then
     $copy = $copy&" - Prepaid "&$dataprepaid
    Else
     $copy = $copy&" - Prepaid £"&$dataprepaid
    EndIf
   EndIf
   if not $datanotified = "" Then
    $copy = $copy&" - Notified "&$datanotified
   EndIf
   if not $dataedit = "" Then
    $copy = $copy&' - Note "'&$dataedit&'"'
   EndIf
   $copy = $copy&" - "&$firstname&" "&@MDAY&"/"&@mon&"/"&@year&" at "&@HOUR&":"&@min&":"&@SEC
   ClipPut($copy)
   Msgbox(0,"Ready","Message ready, CTRL+V to paste in to notes"&@crlf&"Double check message",5)

  case $openbutton
   if FileExists($directory&@year&@mon&$firstname&".xls") Then
    filecopy($directory&@year&@mon&$firstname&".xls",@TempDir&@year&@mon&$firstname&".xls",1)
    Local $sFilePath1 = @TempDir&@year&@mon&$firstname&".xls"
    Local $oExcel = _ExcelBookOpen($sFilePath1,1)
    msgbox(48,"This is a copy","This is a copy version of the original."&@crlf&"Any changes you make in here will not change the original document.")
   else
    msgbox(0,"File not found","File does not exist")
   EndIf

  Case $Clearbutton
   $clearcheck = msgbox(1,"Clear?","Clear all boxes?")
   if $clearcheck = 1 Then
    GUICtrlSetData($ticketinput,"")
    GUICtrlSetData($descriptioninput,"")
    GUICtrlSetData($summarycombo,"")
    GUICtrlSetData($inotifiedinput,"")
    GUICtrlSetData($totalexcinput,"")
    GUICtrlSetData($totalplusinput,"")
   elseif $clearcheck = 2 Then
   EndIf
  Case $logoutbutton
   $logoutcheck = msgbox(1,"Logout?","Logout from username: "&$firstname&"?")
   if $logoutcheck = 1 Then
    $firstname = ""
    $oldthisdate=""
    $oldthistime=""
    login()
   elseif $logoutcheck = 2 Then
   EndIf
  Case $enterbutton
   $entercheck= MsgBox(1,"Continue?","Write this data to the log?")
   if $entercheck = 1 Then
    $datatime=guictrlread($time)
    $dataticket=guictrlread($ticketinput)
    $datasummary=guictrlread($summarycombo)
    $dataedit=guictrlread($descriptioninput)
    $datanotified=GUICtrlRead($inotifiedinput)
    $datatotalexc=guictrlread($totalexcinput)
    $dataprepaid=guictrlread($totalplusinput)
    writetolog()
   elseif $entercheck=2 Then
   EndIf
EndSwitch
WEnd
EndFunc

func writetolog()
if FileExists($directory&@year&@mon&$firstname&".xls") then
  $datatime=guictrlread($time)
  if $datatime = "" Then
   $datatime = "-"
  EndIf
  $dataticket=guictrlread($ticketinput)
  if $dataticket = "" Then
   $dataticket = "-"
  EndIf
  $datasummary=guictrlread($summarycombo)
  if $datasummary = "" Then
   $datasummary = "-"
  EndIf
  $dataedit=guictrlread($descriptioninput)
  if $dataedit = "" Then
   $dataedit="-"
  EndIf
  $datanotified=GUICtrlRead($inotifiedinput)
  if $datanotified = "" Then
   $datanotified = "-"
  EndIf
  $datatotalexc=guictrlread($totalexcinput)
  if $datatotalexc = "" Then
   $datatotalexc = "0"
  EndIf
  $dataprepaid=guictrlread($totalplusinput)
  if $dataprepaid = "" Then
   $dataprepaid = "0"
  EndIf
  Local $sFilePath1 = $directory&@year&@mon&$firstname&".xls"
  Local $oExcel = _ExcelBookOpen($sFilePath1,0)
  _ExcelBookSave($oExcel)
  _ExcelBookClose($oExcel)
  Local $oExcel = _ExcelBookOpen($sFilePath1,0)
  $lineno = _ExcelReadCell($oExcel, 1,100)
  $datewrite = _ExcelWriteCell($oExcel, @MDAY&"/"&@mon&"/"&@year, $lineno, 1)
  $timewrite = _ExcelWriteCell($oExcel, $datatime, $lineno, 2)
  $ticketwrite = _ExcelWriteCell($oExcel, $dataticket, $lineno, 3)
  $summarywrite = _ExcelWriteCell($oExcel, $datasummary, $lineno, 4)
  $informedwrite = _ExcelWriteCell($oExcel, $datanotified, $lineno, 5)
  $priceexcwrite = _ExcelWriteCell($oExcel, $datatotalexc, $lineno, 6)
  $prepaidwrite = _ExcelWriteCell($oExcel, $dataprepaid, $lineno, 7)
  $descriptionwrite = _ExcelWriteCell($oExcel, $dataedit, $lineno, 8)
  $badge = _ExcelWriteCell($oExcel, $firstname, $lineno, 9)
  $newlineno = _ExcelWriteCell($oExcel, $lineno+1, 1, 100)
  _ExcelBookSave($oExcel)
  _ExcelBookClose($oExcel)
  msgbox(0,"Saved","Save complete",1)
Else
  Local $oExcel = _ExcelBookNew(0)
  $datewrite = _ExcelWriteCell($oExcel, "Date", 1, 1)
  $timewrite = _ExcelWriteCell($oExcel, "Time", 1, 2)
  $ticketwrite = _ExcelWriteCell($oExcel, "Ticket", 1, 3)
  $summarywrite = _ExcelWriteCell($oExcel, "Proceed/RUR", 1, 4)
  $informedwrite = _ExcelWriteCell($oExcel, "Informed", 1, 5)
  $priceexcwrite = _ExcelWriteCell($oExcel, "Price EXC VAT", 1, 6)
  $prepaidwrite = _ExcelWriteCell($oExcel, "Total paid", 1, 7)
  $descriptionwrite = _ExcelWriteCell($oExcel, "Description", 1, 8)
  $badge = _ExcelWriteCell($oExcel, "name", 1, 9)
  $newlineno = _ExcelWriteCell($oExcel, 2, 1, 100)
  _ExcelBookSaveAs($oExcel, $directory&@year&@mon&$firstname&".xls", "xls", 0, 1)
  _ExcelBookClose($oExcel)
  writetolog()
EndIf
EndFunc
func startadminlog()
guidelete()
#Region ### START Koda GUI section ### Form=
$Dataentry = GUICreate($firstname&"'s data entry", 324, 561, -1, -1)
GUISetBkColor(0xFF0000)
$summarylabel = GUICtrlCreateLabel("Brief summary", 53, 125, 83, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$summarycombo = GUICtrlCreateCombo("", 13, 153, 163, 25,BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, $inisummarycombo)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$timelabel = GUICtrlCreateLabel("Time", 233, 125, 31, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$time = GUICtrlCreateCombo("", 196, 153, 105, 31, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "9:00-10:00|10:00-11:00|11:00-12:00|12:00-13:00|13:00-14:00|14:00-15:00|15:00-16:00|16:00-17:00|17:00-18:00")
GUICtrlSetFont(-1, 16, 400, 0, "Gloucester MT Extra Condensed")
$ticketlabel = GUICtrlCreateLabel("Ticket number", 50, 197, 83, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$ticketinput = GUICtrlCreateInput("", 13, 226, 163, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER), $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUICtrlSetLimit (-1, 5)
$totalexclabel = GUICtrlCreateLabel("Total EXC VAT", 203, 195, 87, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$totalexcinput = GUICtrlCreateInput("", 196, 223, 105, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$totalpluslabel = GUICtrlCreateLabel("Total Paid", 217, 266, 59, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$totalplusinput = GUICtrlCreateInput("", 196, 295, 105, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$inotifiedllabel = GUICtrlCreateLabel("I notified _ by _", 50, 266, 84, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$inotifiedinput = GUICtrlCreateInput("", 13, 295, 163, 31, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$descriptionlabel = GUICtrlCreateLabel("Description", 128, 336, 67, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$descriptioninput = GUICtrlCreateEdit("", 13, 368, 297, 145,$ES_WANTRETURN)
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUICtrlSetTip(-1, "I.E Definately went ahead with full service")
$enterbutton = GUICtrlCreateLabel("Enter data", 228, 518, 82, 36, $WS_BORDER)
GUICtrlSetFont(-1, 20, 400, 0, "Gloucester MT Extra Condensed")
$loggedinlabel = GUICtrlCreateLabel("Logged in: "&$firstname, 13, 8, 120, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$logoutbutton = GUICtrlCreateLabel("Log out", 272, 8, 46, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$logintimelabel = GUICtrlCreateLabel("Log in time: "&@hour&":"&@min, 13, 40, 150, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$previouslogintimelabel = GUICtrlCreateLabel("Previous Log in: "&$oldthistime&" - "&$oldthisdate, 13, 72, 250, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$Clearbutton = GUICtrlCreateLabel("Clear", 13, 527, 32, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$openbutton = GUICtrlCreateLabel("Open", 279, 38, 33, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
$creatmessagebutton = GUICtrlCreateLabel("Create Message", 62, 526, 88, 27, $WS_BORDER)
GUICtrlSetFont(-1, 15, 400, 0, "Gloucester MT Extra Condensed")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   GUISetState(@SW_MINIMIZE)
  case $creatmessagebutton
   $datasummary=guictrlread($summarycombo)
   $dataedit=guictrlread($descriptioninput)
   $datanotified=GUICtrlRead($inotifiedinput)
   $datatotalexc=guictrlread($totalexcinput)
   $dataprepaid=guictrlread($totalplusinput)
   $copy = ""
   if not $datasummary = "" Then
    $copy = $datasummary
   EndIf
   if not $datatotalexc = "" Then
    if StringInStr ($datatotalexc,"£") Then
     $copy = $copy&" - "&$datatotalexc&"+VAT"
    Else
     $copy = $copy&" - £"&$datatotalexc&"+VAT"
    EndIf
   EndIf
   if not $dataprepaid = "" Then
    if StringInStr ($dataprepaid,"£") Then
     $copy = $copy&" - Prepaid "&$dataprepaid
    Else
     $copy = $copy&" - Prepaid £"&$dataprepaid
    EndIf
   EndIf
   if not $datanotified = "" Then
    $copy = $copy&" - Notified "&$datanotified
   EndIf
   if not $dataedit = "" Then
    $copy = $copy&' - Note "'&$dataedit&'"'
   EndIf
   $copy = $copy&" - "&$firstname&" "&@MDAY&"/"&@mon&"/"&@year&" at "&@HOUR&":"&@min&":"&@SEC
   ClipPut($copy)
   Msgbox(0,"Ready","Message ready, CTRL+V to paste in to notes"&@crlf&"Double check message",5)

  case $openbutton
   if FileExists($directory&@year&@mon&$firstname&".xls") Then
    filecopy($directory&@year&@mon&$firstname&".xls",@TempDir&@year&@mon&$firstname&".xls",1)
    Local $sFilePath1 = @TempDir&@year&@mon&$firstname&".xls"
    Local $oExcel = _ExcelBookOpen($sFilePath1,1)
    msgbox(48,"This is a copy","This is a copy version of the original."&@crlf&"Any changes you make in here will not change the original document.")
   else
    msgbox(0,"File not found","File does not exist")
   EndIf

  Case $Clearbutton
   $clearcheck = msgbox(1,"Clear?","Clear all boxes?")
   if $clearcheck = 1 Then
    GUICtrlSetData($ticketinput,"")
    GUICtrlSetData($descriptioninput,"")
    GUICtrlSetData($summarycombo,"")
    GUICtrlSetData($inotifiedinput,"")
    GUICtrlSetData($totalexcinput,"")
    GUICtrlSetData($totalplusinput,"")
   elseif $clearcheck = 2 Then
   EndIf
  Case $logoutbutton
   $logoutcheck = msgbox(1,"Logout?","Logout from username: "&$firstname&"?")
   if $logoutcheck = 1 Then
    $firstname = ""
    $oldthisdate=""
    $oldthistime=""
    login()
   elseif $logoutcheck = 2 Then
   EndIf
  Case $enterbutton
   $dataedit=guictrlread($descriptioninput)
   if StringInStr($dataedit,"add user") or StringInStr($dataedit,"adduser") Then
    $newstring = stringreplace($dataedit,"user ",";")
    $array = stringsplit($newstring,";")
    $newusername = $array[2]
    iniwrite($ini,$newusername,"login",1)
    $inilist = iniread($ini,"logincombolist","names","")
    $newinilist = $inilist&"|"&$newusername
    iniwrite($ini,"logincombolist","names",$newinilist)
    msgbox(0,"Done",'Added new user "'&$newusername&'"',2)
   EndIf
   if StringInStr($dataedit,"delete user") or StringInStr($dataedit,"deleteuser") or StringInStr($dataedit,"removeuser") or StringInStr($dataedit,"remove user") Then
    $newstring = stringreplace($dataedit,"user ",";")
    $array = stringsplit($newstring,";")
    $newusername = $array[2]
    IniDelete($ini,$newusername)
    $inilist = iniread($ini,"logincombolist","names","")
    $newinilist = stringreplace($inilist,"|"&$newusername,"")
    iniwrite($ini,"logincombolist","names",$newinilist)
    msgbox(0,"Done",'Removed user "'&$newusername&'"',2)
   EndIf
  EndSwitch
WEnd
EndFunc
login()
Link to comment
Share on other sites

  • Developers

You are not Returning in your Func's but Calling the original Func Again... hence the recursion.

EG: Login() calls startadminlog() and startadminlog() Calls login().

Review your program flow and start using return to return to the Func that Called.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

i tried the return function you mentioned but its not doing what i need for this program, when i recall a function its because i need that function to restart, with the return function it doesn't go back round.

func writetolog()
if FileExists($directory&@year&@mon&$firstname&".xls") then
$datatime=guictrlread($time)
if $datatime = "" Then
$datatime = "-"
EndIf
$dataticket=guictrlread($ticketinput)
if $dataticket = "" Then
$dataticket = "-"
EndIf
$datasummary=guictrlread($summarycombo)
if $datasummary = "" Then
$datasummary = "-"
EndIf
$dataedit=guictrlread($descriptioninput)
if $dataedit = "" Then
$dataedit="-"
EndIf
$datanotified=GUICtrlRead($inotifiedinput)
if $datanotified = "" Then
$datanotified = "-"
EndIf
$datatotalexc=guictrlread($totalexcinput)
if $datatotalexc = "" Then
$datatotalexc = "0"
EndIf
$dataprepaid=guictrlread($totalplusinput)
if $dataprepaid = "" Then
$dataprepaid = "0"
EndIf
Local $sFilePath1 = $directory&@year&@mon&$firstname&".xls"
Local $oExcel = _ExcelBookOpen($sFilePath1,0)
_ExcelBookSave($oExcel)
_ExcelBookClose($oExcel)
Local $oExcel = _ExcelBookOpen($sFilePath1,0)
$lineno = _ExcelReadCell($oExcel, 1,100)
$datewrite = _ExcelWriteCell($oExcel, @MDAY&"/"&@mon&"/"&@year, $lineno, 1)
$timewrite = _ExcelWriteCell($oExcel, $datatime, $lineno, 2)
$ticketwrite = _ExcelWriteCell($oExcel, $dataticket, $lineno, 3)
$summarywrite = _ExcelWriteCell($oExcel, $datasummary, $lineno, 4)
$informedwrite = _ExcelWriteCell($oExcel, $datanotified, $lineno, 5)
$priceexcwrite = _ExcelWriteCell($oExcel, $datatotalexc, $lineno, 6)
$prepaidwrite = _ExcelWriteCell($oExcel, $dataprepaid, $lineno, 7)
$descriptionwrite = _ExcelWriteCell($oExcel, $dataedit, $lineno, 8)
$badge = _ExcelWriteCell($oExcel, $firstname, $lineno, 9)
$newlineno = _ExcelWriteCell($oExcel, $lineno+1, 1, 100)
_ExcelBookSave($oExcel)
_ExcelBookClose($oExcel)
msgbox(0,"Saved","Save complete",1)
Else
Local $oExcel = _ExcelBookNew(0)
; ^ this is causing the error
$datewrite = _ExcelWriteCell($oExcel, "Date", 1, 1)
$timewrite = _ExcelWriteCell($oExcel, "Time", 1, 2)
$ticketwrite = _ExcelWriteCell($oExcel, "Ticket", 1, 3)
$summarywrite = _ExcelWriteCell($oExcel, "Proceed/RUR", 1, 4)
$informedwrite = _ExcelWriteCell($oExcel, "Informed", 1, 5)
$priceexcwrite = _ExcelWriteCell($oExcel, "Price EXC VAT", 1, 6)
$prepaidwrite = _ExcelWriteCell($oExcel, "Total paid", 1, 7)
$descriptionwrite = _ExcelWriteCell($oExcel, "Description", 1, 8)
$badge = _ExcelWriteCell($oExcel, "name", 1, 9)
$newlineno = _ExcelWriteCell($oExcel, 2, 1, 100)
_ExcelBookSaveAs($oExcel, $directory&@year&@mon&$firstname&".xls", "xls", 0, 1)
_ExcelBookClose($oExcel)
writetolog()
EndIf
EndFunc

this is the function thats causing errors

i just tried this and i get absolutely nothing, nothing seem to open excel, any ideas? anyone got a script just to open excel and ill see if it works?

ObjCreate("Excel.Application")
Edited by joboy2k
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...