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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
-- Fichier à ouvrir et à créer
set Nom1 to "Macintosh HD:Users:zzzzz:Desktop:Import Articles:Import Produits.xlsx" -- Nom du fichier*xlSX
set FichierTXTFam to "Macintosh HD:Users:zzzzz:Desktop:Import Articles:Fam.txt" -- Nom du 2EME fichier*A CREER TXT
set FichierTXTProd to "Macintosh HD:Users:zzzzzz:Desktop:Import Articles:Prod.txt" -- Nom du 3EME fichier*A CREER TXT
set FichierTXTProdRetails to "Macintosh HD:Users:zzzzzz:Desktop:Import Articles:Prod Retails.txt" -- Nom du 1 ER fichier*A CREER TXT
-- 1er Message - Présentation -
set chaineMessage1 to "Cette application va copier vos produits de XXXXXXX vers une société B"
set tempRep1 to display dialog chaineMessage1 buttons {"Arreter", "Continuer"} default button "Continuer"
-- 2eme Message Ou exporter
set message to "Dans quelle entreprise souhaitez-vous exporter vos produits"
set tempVar to display dialog message buttons {"Annuler", "AAAAAA", "ZZZZZZZ"} default button "Annuler"
set boutonAppuye to button returned of tempVar
set SaisieSiren to ""
if boutonAppuye is "AAAAAA" then
set SaisieSiren to "817856842"
display dialog "Vous avez choisi de transferer les produits vers " & boutonAppuye buttons {"Ok"}
else
if boutonAppuye is "ZZZZZZZ" then
set SaisieSiren to "123456789"
display dialog "Vous avez choisi de transferer les produits vers " & boutonAppuye buttons {"Ok"}
else
set SaisieSiren to ""
end if
end if
-- 2ème Message - Le Coef -
set Coef to display dialog "Quel Coeficient voulez-vous appliquer pour le calcul du Prix d'achat" default answer ""
set SaisieCoef to text returned of Coef
--set SaisieCoef to SaisieCoef as number
set Coef1 to round ((100 / SaisieCoef) * 100) / 100
-- 3ème Message - Vérif du calcul avec Coef
set chaineMessage2 to "Vous avez saisie un coef de : " & SaisieCoef & "*
Exemple :*
Un produit au prix de Vente de 100 sur soc A aura un Prix d'Achat à :* " & Coef1 & " "
set tempRep2 to display dialog chaineMessage2 buttons {"Arreter", "Retour", "Suivant"}
-- if button returned of tempRep2 = "Corriger" then
-- end if
-- 4ème Message - Donner le numéro d'export pour définir produits
set Export to display dialog "Taper le n° Export pour le choix des produits" default answer ""
set SaisieExport to text returned of Export
set chaineMessage3 to "Vous avez saisie l'export n° : " & SaisieExport
set tempRep3 to display dialog chaineMessage3 buttons {"Arreter", "Retour", "Suivant"}
-- if button returned of tempRep3 = "Corriger" then
-- run Quest3
-- end if
-- if button returned of tempRep3 = "Arreter" then
-- BoutonArreter()
-- end if
-- Ouverture du fichier excel contenant un lien SQL avec Gestion
tell application "Microsoft Excel" -- Ouvrir excel
set silently of window 1 to true
--set visible to false
open text file filename Nom1 origin Macintosh
-- Saisie des réponses dialogues dans feuille DATA
select sheet "DATA"
set value of cell ("B" & "2") to SaisieCoef
set value of cell ("B" & "3") to SaisieExport
set value of cell ("B" & "4") to SaisieSiren
-- Actualisation du SQL
select sheet "Produits"
set destinationWorkbook to workbook "Import Produits.xlsx"
refresh all destinationWorkbook
delay 20 -- Sans le tempo j'ai un message erreur excel comme quoi
-- Calcul du nb de produits à exporter
select sheet "DATA"
set NbExport to (get value of cell ("C" & "2")) -- Je veux compter les lignes remplies de la feuille Produits de A2 à A1000
set chaineMessage4 to "Vous avez demandez l'export de : " & NbExport & " produits -- Pb le message s'ouvre sur feuille excel, comment cacher excel
Voulez-vous continuer ?
(Si oui, le temps d'attente de l'export est d'une minute)"
set tempRep4 to display dialog chaineMessage4 buttons {"Arreter", "Continuer"}
-- Création de 3 fichiers txt
select sheet "Fam"
save
save as worksheet "Fam" of active workbook filename FichierTXTFam file format current platform text file format with overwrite
select sheet "Prod Retails"
save as worksheet "Prod Retails" of active workbook filename FichierTXTProdRetails file format current platform text file format with overwrite
select sheet "Prod"
save as worksheet "Prod" of active workbook filename FichierTXTProd file format current platform text file format with overwrite
close active workbook saving yes
end tell
set FichierTXTProdRetails2 to POSIX path of FichierTXTProdRetails
set FichierTXTFam2 to POSIX path of FichierTXTFam
set FichierTXTProd2 to POSIX path of FichierTXTProd
-- Ouverture de la Gestion et import du 1er fichier
tell application "La Gestion" -- ouvrir la gestion
ouvrir "123456789" -- ouvrir entreprise n° siren*
importer FichierTXTProdRetails2 -- importer le fichier d'import
-- changement société et import du 2 et 3eme fichier
ouvrir SaisieSiren --SaisieSiren -- ouvrir entreprise n° siren
importer FichierTXTFam2 -- importer le fichier d'import
importer FichierTXTProd2 -- importer le fichier d'import
end tell
activate
-- Message terminé
display dialog "Terminé" |
Partager