Jump to content

Recommended Posts

Posted

is there any way for switch case to continue running and not repeat itself

Switch $selectedflag[$charcnt]
    case 11, 12, 15, 17, 19, 20, 21, 24
        MsgBox (0,"ok", "hit")
EndSwitch

i have programs that save in a selected folder  the switch case helps me to save only those programs that i need 

example i type 11 and 12 and the select folder window comes up now so far so good it runs 11 but another select folder menu pops up when i type 12 which i dont want any solutions.

Posted

Post a runnable script that shows what it is you're doing. Then, explain what you want a lot better than your first post, because I'm not getting what you want.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)
#include <ClipBoard.au3>
#include <ClipBoard.au3>
#include <array.au3>
#include <Date.au3>
#include <Excel.au3>
#include <ExcelConstants.au3>
#include <MsgBoxConstants.au3>
$variable1 = TimerInit
AutoItSetOption ( "WinTitleMatchMode",2)
AutoItSetOption ( 'MouseCoordMode',0)

$reportname = StringSplit("                                                                                                    ","")
$reportname[0]= "Instructions"
$reportname[1] = "1 SO (Outstanding Order)"
$reportname[2] = "2 PRP Prod"
$reportname[3] = "3 PRP Pur"
$reportname[4] = "4 Prod Claim"
$reportname[5] = "5 Pur Claim"
$reportname[6] = "6 Buy to whs "
$reportname[7] = "7 PRP whs (W2P and P2W)"
$reportname[8] = "8 Proj to Proj"
$reportname[9] = "9 Trigger list  "
$reportname[10]= "10 Sub con claim"
$charcnt = 0
$reportname_show = ""
while $reportname[$charcnt] <> " "
    $reportname_show = $reportname_show & @CR & $reportname[$charcnt]
    $charcnt = $charcnt + 1
 WEnd

$selection = InputBox("Baan Reports Selection",$reportname_show & @CR & @CR &"For instructions on what the program does key in 26" & @CR & "Please Enter selection as Numbers, with 1 space in-between" ,""," M",350,550,650,450)
If @error Then Exit

sleep(10)
$charcnt = 1
$selected = ""
$selectedflag = StringSplit("                                                                                                    ","")
$reportname[0] = ""


while $charcnt < 40
    if int(Stringmid($selection, $charcnt,1)) >= 0 then
        if int(Stringmid($selection, $charcnt,2)) < 10 then
            $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,1))]
            $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,1))
            $charcnt = $charcnt + 2
        Else
            $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,2))]
            $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,2))
            $charcnt = $charcnt + 3
        EndIf
    EndIf
 WEnd



$input = MsgBox(1, "", "Reports Selected -> START ALL RANGE:" & @CR & $selected & @CR & @CR &"Click Ok to proceed, Cancel to End")

if $input = 2 Then
    Exit
 EndIf
 
 $Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
$yy=StringFormat("%02i",@YEAR-2000)
$mm=StringFormat("%02i",Int(@MON))
$dd=StringFormat("%02i",Int(@MDAY))


$Baan_exist = 0
If WinExists("Menu browser [User: ") then
$Baan_exist = 1
EndIf

    $charcnt = 1
while $charcnt < 40
If $selectedflag[$charcnt] = 26 Then
MsgBox(1, "Instructions", "1) Enter the report number in the box with a space in between" & @LF & "2) Reports 1 to 20 are reports with all range" & @LF & "3) Report 21 runs all reports from 1 to 20" & @LF & "4) Reports 22 and 23 run with selectable range" & @LF & "5) Report 24 runs a macro to save"& @LF & "6) Report 25 runs reports 22 to 24 together"& @LF &"7) Each report is saved in a default folder and the setting can be changed easily")
    Exit
if $input = 2 Then
    Exit
 EndIf
 EndIf
Switch $selectedflag[$charcnt]
    case 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
$sFileSelectFolder = FileSelectFolder("Select a folder", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
        Exit
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
EndIf

if $selectedflag[$charcnt] = 1 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 2 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 3 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 4 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 5 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 6 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 7 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 8 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 9 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
if $selectedflag[$charcnt] = 10 Or $selectedflag[$charcnt] = 21 Then

end if
sleep(10)
EndSwitch

$charcnt = $charcnt + 1
WEnd

i want the fileselect folder to only appear once when i key in  multiple numbers and not appear at all when i key in 26.

if you want to try it you will need to fill in the program.

Edited by yasha
Posted

Add this before the While line

Global $flag = 0 ; <<<<<<<<<<<<<
While $charcnt < 40

And change this part too.

If Not $flag Then ; <<<<<<<<<<<<<<<<< Add this
                $sFileSelectFolder = FileSelectFolder("Select a folder", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download")
                If @error Then
                    ; Display the error message.
                    MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
                    Exit
                Else
                    ; Display the selected folder.
                    MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
                    $Flag = 1 ; <<<<<<<<<<<<<<<<< Add this
                EndIf
            EndIf ; <<<<<<<<<<<<<<<<< Add this

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

@BrewManNHthanks that worked great now can u also help me on this 

$oExcel = ObjCreate("Excel.Application")                   ; Create an Excel Object
$oExcel.Visible = 1  ; Let Excel show itself
$oExcel = _Excel_Open()
$oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_PUR_ORDER " & $yy & $mm & $dd & ".xls")
;$sWorkbook = "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\"& $YY & $MM & $DD & " INV_PLAN_PUR_ORDER.xlsx"
$oExcel.ActiveWorkbook.SaveAs ( $sFileSelectFolder &"\INV_PLAN_PUR_ORDER " & $yy & $mm & $dd & ".xlsx",51,"","",False,False)
$oExcel.ActiveWorkBook.Close

i want to convert xls file to xlsx 

the problem here is that its super unstable and the person wants it in this format .

ps i have no idea what the 51 after xlsx is i took this from the net and the excel save as udf  keeps giving me this "C:\Users\etg.sgp.sysplan2\Documents\Program 2.au3"  : ==> Variable used without being declared.:

on this line _Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlsx, True)

even when i declare everything

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
  • Recently Browsing   0 members

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