VB_PtitCat
Messages postés197Date d'inscriptionmercredi 30 mai 2007StatutMembreDernière intervention13 mai 2009
-
30 mai 2007 à 13:52
VB_PtitCat
Messages postés197Date d'inscriptionmercredi 30 mai 2007StatutMembreDernière intervention13 mai 2009
-
30 mai 2007 à 14:56
Bonjours, Voilà je m'escuse déja pour les fructeuses fautes d'othographe que je vais faire, mais bon le français n'est pas mon fort Donc voilà mon problème, en fait la ou je travaille je dois faire une macros sous Excel:
Voilà ce que j'ai fais pour le moment (Attention faut s'accrocher, je suis pas fan des commentaires) :
Contenue de mon module :
' Fontion permettant de récupérer un entier d'un fichier
Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
' Fontion permettant de récupérer une chaîne de caractères d'un fichier
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
' Fontion permettant de convertir ,en VB, la longueur d'une chaîne de caractères écrite en C
Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Contenue du géneral CreaDB :
Sub creaDB()
Dim I, J, P, k, l As Integer
Dim ColGroup As Integer
Dim ColComment As Integer
Dim ColLogged As Integer
Dim ColEventLogged As Integer
Dim ColEventLoggingPriority As Integer
Dim ColRetentiveValue As Integer
Dim ColRetentiveAlarmParameters As Integer
Dim ColAlarmValueDeadband As Integer
Dim ColAlarmDevDeadband As Integer
Dim ColEngUnits As Integer
Dim ColInitialValue As Integer
Dim ColMinEU As Integer
Dim ColMaxEU As Integer
Dim ColDeadband As Integer
Dim ColLogDeadband As Integer
Dim ColLoLoAlarmState As Integer
Dim ColLoLoAlarmValue As Integer
Dim ColLoLoAlarmPri As Integer
Dim ColLoAlarmState As Integer
Dim ColLoAlarmValue As Integer
Dim ColLoAlarmPri As Integer
Dim ColHiAlarmState As Integer
Dim ColHiAlarmValue As Integer
Dim ColHiAlarmPri As Integer
Dim ColHiHiAlarmState As Integer
Dim ColHiHiAlarmValue As Integer
Dim ColHiHiAlarmPri As Integer
Dim ColMinorDevAlarmState As Integer
Dim ColMinorDevAlarmValue As Integer
Dim ColMinorDevAlarmPri As Integer
Dim ColMajorDevAlarmState As Integer
Dim ColMajorDevAlarmValue As Integer
Dim ColMajorDevAlarmPri As Integer
Dim ColDevTarget As Integer
Dim ColROCAlarmState As Integer
Dim ColROCAlarmValue As Integer
Dim ColROCAlarmPri As Integer
Dim ColROCTimeBase As Integer
Dim ColMinRaw As Integer
Dim ColMaxRaw As Integer
Dim ColConversion As Integer
Dim ColAccessName As Integer
Dim ColItemUseTagname As Integer
Dim ColItemName As Integer
Dim ColReadOnly As Integer
Dim ColAlarmComment As Integer
Dim ColAlarmAckModel As Integer
Dim ColLoLoAlarmDisable As Integer
Dim ColLoAlarmDisable As Integer
Dim ColHiAlarmDisable As Integer
Dim ColHiHiAlarmDisable As Integer
Dim ColMinDevAlarmDisable As Integer
Dim ColMajDevAlarmDisable As Integer
Dim ColRocAlarmDisable As Integer
Dim ColLoLoAlarmInhibitor As Integer
Dim ColLoAlarmInhibitor As Integer
Dim ColHiAlarmInhibitor As Integer
Dim ColHiHiAlarmInhibitor As Integer
Dim ColMinDevAlarmInhibitor As Integer
Dim ColMajDevAlarmInhibitor As Integer
Dim ColRocAlarmInhibitor As Integer
Dim ColSymbolicName As Integer
Dim ColInitialDisc As Integer
Dim ColOffMsg As Integer
Dim ColOnMsg As Integer
Dim ColAlarmState As Integer
Dim ColAlarmPri As Integer
Dim ColDConversion As Integer
Dim ColDSCAlarmDisable As Integer
Dim ColDSCAlarmInhibitor As Integer
Dim fic_ini As String
Dim NumVanne As String
Dim Item As String
Dim Standard As String
Dim chaine_BU As String
Dim chaine_Comm As String
Dim chaine_Ala As String
Dim chaine_Eve As String
Dim chaine_Onmsg As String
Dim chaine_Offmsg As String
Dim chaine_priala As String
Dim chaine_prieve As String
Dim chaine_ComAla As String
Dim chaine_access As String
Dim Tcom As Integer
Dim Tala As Integer
Dim Tpriala As Integer
Dim Teve As Integer
Dim Tprieve As Integer
Dim TonMsg As Integer
Dim ToffMsg As Integer
Dim Tcomala As Integer
Dim Tbu As Integer
Dim Taccess As Integer
Dim V_comm As String
Dim V_ala As String
Dim V_priala As String
Dim V_eve As String
Dim V_prieve As String
Dim V_onmsg As String
Dim V_offmsg As String
Dim V_comala As String
Dim V_access As String
Dim rep As Integer
I = 1
J = 2
k = 1
While (Worksheets("BD").Cells(I, 1).Value <> "") Or I > 20000
If InStr(1, Worksheets("BD").Cells(I, 1).Value, "ioMOTVANNE", 0) <> 0 Then
While (Worksheets("BD").Cells(k, 1).Value <> "") Or k > 20000
If (Worksheets("BD").Cells(k, 1).Value = ":IODisc") Then
Worksheets("RESULTAT").Cells(J, 1).Value = ":IODisc"
For l = 1 To 22
If (Worksheets("BD").Cells(k, l).Value = "Group") Then
ColGroup = l
Worksheets("RESULTAT").Cells(J, ColGroup).Value = "Group"
End If
If (Worksheets("BD").Cells(k, l).Value = "Comment") Then
ColComment = l
Worksheets("RESULTAT").Cells(J, ColComment).Value = "Comment"
End If
If (Worksheets("BD").Cells(k, l).Value = "Logged") Then
ColLogged = l
Worksheets("RESULTAT").Cells(J, ColLogged).Value = "Logged"
End If
If (Worksheets("BD").Cells(k, l).Value = "EventLogged") Then
ColEventLogged = l
Worksheets("RESULTAT").Cells(J, ColEventLogged).Value = "EventLogged"
End If
If (Worksheets("BD").Cells(k, l).Value = "EventLoggingPriority") Then
ColEventLoggingPriority = l
Worksheets("RESULTAT").Cells(J, ColEventLoggingPriority).Value = "EventLoggingPriority"
End If
If (Worksheets("BD").Cells(k, l).Value = "RetentiveValue") Then
ColRetentiveValue = l
Worksheets("RESULTAT").Cells(J, ColRetentiveValue).Value = "RetentiveValue"
End If
If (Worksheets("BD").Cells(k, l).Value = "InitialDisc") Then
ColInitialDisc = l
Worksheets("RESULTAT").Cells(J, ColInitialDisc).Value = "InitialDisc"
End If
If (Worksheets("BD").Cells(k, l).Value = "OffMsg") Then
ColOffMsg = l
Worksheets("RESULTAT").Cells(J, ColOffMsg).Value = "OffMsg"
End If
If (Worksheets("BD").Cells(k, l).Value = "OnMsg") Then
ColOnMsg = l
Worksheets("RESULTAT").Cells(J, ColOnMsg).Value = "OnMsg"
End If
If (Worksheets("BD").Cells(k, l).Value = "AlarmState") Then
ColAlarmState = l
Worksheets("RESULTAT").Cells(J, ColAlarmState).Value = "AlarmState"
End If
If (Worksheets("BD").Cells(k, l).Value = "AlarmPri") Then
ColAlarmPri = l
Worksheets("RESULTAT").Cells(J, ColAlarmPri).Value = "AlarmPri"
End If
If (Worksheets("BD").Cells(k, l).Value = "DConversion") Then
ColDConversion = l
Worksheets("RESULTAT").Cells(J, ColDConversion).Value = "DConversion"
End If
If (Worksheets("BD").Cells(k, l).Value = "AccessName") Then
ColAccessName = l
Worksheets("RESULTAT").Cells(J, ColAccessName).Value = "AccessName"
End If
If (Worksheets("BD").Cells(k, l).Value = "ItemUseTagname") Then
ColItemUseTagname = l
Worksheets("RESULTAT").Cells(J, ColItemUseTagname).Value = "ItemUseTagname"
End If
If (Worksheets("BD").Cells(k, l).Value = "ItemName") Then
ColItemName = l
Worksheets("RESULTAT").Cells(J, ColItemName).Value = "ItemName"
End If
If (Worksheets("BD").Cells(k, l).Value = "ReadOnly") Then
ColReadOnly = l
Worksheets("RESULTAT").Cells(J, ColReadOnly).Value = "ReadOnly"
End If
If (Worksheets("BD").Cells(k, l).Value = "AlarmComment") Then
ColAlarmComment = l
Worksheets("RESULTAT").Cells(J, ColAlarmComment).Value = "AlarmComment"
End If
If (Worksheets("BD").Cells(k, l).Value = "AlarmAckModel") Then
ColAlarmAckModel = l
Worksheets("RESULTAT").Cells(J, ColAlarmAckModel).Value = "AlarmAckModel"
End If
If (Worksheets("BD").Cells(k, l).Value = "DSCAlarmDisable") Then
ColDSCAlarmDisable = l
Worksheets("RESULTAT").Cells(J, ColDSCAlarmDisable).Value = "DSCAlarmDisable"
End If
If (Worksheets("BD").Cells(k, l).Value = "DSCAlarmInhibitor") Then
ColDSCAlarmInhibitor = l
Worksheets("RESULTAT").Cells(J, ColDSCAlarmInhibitor).Value = "DSCAlarmInhibitor"
End If
If (Worksheets("BD").Cells(k, l).Value = "SymbolicName") Then
ColSymbolicName = l
Worksheets("RESULTAT").Cells(J, ColSymbolicName).Value = "SymbolicName"
End If
Next l
J = J + 1
End If
k = k + 1
Wend
End If
I = I + 1
Wend
I = 1
While (Worksheets("BD").Cells(I, 1).Value <> "") Or I > 20000
If InStr(1, Worksheets("BD").Cells(I, 1).Value, "ioMOTVANNE", 0) <> 0 Then
Item = Worksheets("BD").Cells(I, 1).Value
Standard = Mid(Item, 12, 3)
NumVanne = Right(Worksheets("BD").Cells(I, 1).Value, 3)
P = 0
fic_ini = "infobit.ini"
chaine_BU = String$(20, 0)
Tbu = GetPrivateProfileString(Standard, "BITUTILISE", "0", chaine_BU, 20, fic_ini)
M = Tbu
While (P <> 16)
If (Mid(chaine_BU, M, 1)) <> 0 Then
V_comm = "COMMENTAIRE" & Format(CStr(P), "0#")
V_ala = "ALARME" & Format(CStr(P), "0#")
V_priala = "PRIOALARME" & Format(CStr(P), "0#")
V_eve = "EVENEMENT" & Format(CStr(P), "0#")
V_prieve = "PRIOEVEN" & Format(CStr(P), "0#")
V_onmsg = "OnMsg" & Format(CStr(P), "0#")
V_offmsg = "OffMsg" & Format(CStr(P), "0#")
V_comala = "CommALA" & Format(CStr(P), "0#")
V_access = "ACCESSNAME" & Format(CStr(P), "0#")
chaine_Comm = String$(100, 0)
Tcom = GetPrivateProfileString(Standard, V_comm, "", chaine_Comm, 100, fic_ini)
If (chaine_Comm) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini:" + Standard + " " + V_comm + " est vide, vérifiez le fichier " + fic_ini + (Chr(13) & Chr(10)) + "Souhaitez-vous ouvrir NotePad afin de modifier ces incoérances ? ", 20, "INCOHERANCE!!")
If (rep) = 6 Then
AppActivate (Shell("C:\WINDOWS\notepad.exe", 1))
Else
End
End If
End If
chaine_Ala = String$(100, 0)
Tala = GetPrivateProfileString(Standard, V_ala, "", chaine_Ala, 100, fic_ini)
If (chaine_Ala) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_ala + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini + ".ini" For Output As #1
End If
End If
chaine_priala = String$(100, 0)
Tpriala = GetPrivateProfileString(Standard, V_priala, "", chaine_priala, 100, fic_ini)
If (chaine_priala) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_priala + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
chaine_Eve = String$(100, 0)
Teve = GetPrivateProfileString(Standard, V_eve, "", chaine_Eve, 100, fic_ini)
If (chaine_Eve) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_eve + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
chaine_prieve = String$(100, 0)
Tprieve = GetPrivateProfileString(Standard, V_prieve, "", chaine_prieve, 100, fic_ini)
If (chaine_prieve) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_prieve + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
chaine_Onmsg = String$(100, 0)
TonMsg = GetPrivateProfileString(Standard, V_onmsg, "", chaine_Onmsg, 100, fic_ini)
If (chaine_Onmsg) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_onmsg + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
chaine_Offmsg = String$(100, 0)
ToffMsg = GetPrivateProfileString(Standard, V_offmsg, "", chaine_Offmsg, 100, fic_ini)
If (chaine_Offmsg) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_offmsg + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
chaine_ComAla = String$(100, 0)
Tcomala = GetPrivateProfileString(Standard, V_comala, "", chaine_ComAla, 100, fic_ini)
If (chaine_ComAla) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_comala + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
chaine_access = String$(100, 0)
Taccess = GetPrivateProfileString(Standard, V_access, "", chaine_access, 100, fic_ini)
If (chaine_access) = String$(100, 0) Then
rep = MsgBox("Dans le fichier ini :" + (Chr(13) & Chr(10)) + (Chr(13) & Chr(10)) + Standard + " " + V_acces + " est vide, vérifiez le fichier " + fic_ini, 20, "INCOHERANCE!!")
If (rep) = 7 Then
End
Else
Open "C:\WINDOWS" + fic_ini For Output As #1
End If
End If
Worksheets("RESULTAT").Cells(J, 1).Value = "IodVanne" + NumVanne + "_B" + Format(CStr(P), "0#")
Worksheets("RESULTAT").Cells(J, ColItemName).Value = Item + "." + Format(CStr(P), "0#")
Worksheets("RESULTAT").Cells(J, ColGroup).Value = "$System"
Worksheets("RESULTAT").Cells(J, ColComment).Value = Left$(chaine_Comm, Tcom)
Worksheets("RESULTAT").Cells(J, ColLogged).Value = "No"
Worksheets("RESULTAT").Cells(J, ColEventLogged).Value = Left$(chaine_Eve, Teve)
Worksheets("RESULTAT").Cells(J, ColEventLoggingPriority).Value = Left$(chaine_prieve, Tprieve)
Worksheets("RESULTAT").Cells(J, ColRetentiveValue).Value = "No"
Worksheets("RESULTAT").Cells(J, ColInitialDisc).Value = "Off"
Worksheets("RESULTAT").Cells(J, ColOffMsg).Value = Left$(chaine_Offmsg, ToffMsg)
Worksheets("RESULTAT").Cells(J, ColOnMsg).Value = Left$(chaine_Onmsg, TonMsg)
Worksheets("RESULTAT").Cells(J, ColAlarmState).Value = Left$(chaine_Ala, Tala)
Worksheets("RESULTAT").Cells(J, ColAlarmPri).Value = Left$(chaine_priala, Tpriala)
Worksheets("RESULTAT").Cells(J, ColDConversion).Value = "Dircet"
Worksheets("RESULTAT").Cells(J, ColAccessName).Value = Left$(chaine_access, Taccess)
Worksheets("RESULTAT").Cells(J, ColItemUseTagname).Value = "No"
Worksheets("RESULTAT").Cells(J, ColReadOnly).Value = "No"
Worksheets("RESULTAT").Cells(J, ColAlarmComment).Value = Left$(chaine_ComAla, Tcomala)
Worksheets("RESULTAT").Cells(J, ColAlarmAckModel).Value = "0"
Worksheets("RESULTAT").Cells(J, ColDSCAlarmDisable).Value = "0"
Worksheets("RESULTAT").Cells(J, ColDSCAlarmInhibitor).Value = ""
Worksheets("RESULTAT").Cells(J, ColSymbolicName).Value = ""
M = M - 1
P = P + 1
J = J + 1
Else
M = M - 1
P = P + 1
End If
Wend
End If
I = I + 1
Wend
End Sub
Comme vous pouvez le remarquer il manque des lignes :)
en effet j'avais essayé d'ouvrir mon fichier ini avec:
Open "C:\WINDOWS" + fic_ini For Output As #1
Mais celà n'ouvre nullement le notepad, alors j'ai decidé d'ouvrir d'abord le notepad:
AppActivate (Shell("C:\WINDOWS\notepad.exe", 1))
puis de lui dire quel fichier ouvrir (afin de le corriger) grace a VB mais je ne trouve pas du tout comment faire, si quelqu'un pouvez m'aidez ca serrai super
VB_PtitCat
Messages postés197Date d'inscriptionmercredi 30 mai 2007StatutMembreDernière intervention13 mai 2009 30 mai 2007 à 14:08
lol non pas du tout j'ai même pas un payes complète lol je suis apprenti :) je fais un BTS par alternance :)
et j'avais prevenue que j'était pas doué en ortho, mrc pour ton aide je vais voir tout de suite
VB_PtitCat
Messages postés197Date d'inscriptionmercredi 30 mai 2007StatutMembreDernière intervention13 mai 2009 30 mai 2007 à 14:18
En fait j'ai déja essayé cette technique j'en é essayé moult pour te dir, mais quand j'utilise celle-ci, je place ceci dans mon module
'Déclaration de la fonction ShellExecute Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'Constantes déterminant le mode d'affichage de la fenêntre Private Const SW_SHOWDEFAULT = 10
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOWNORMAL = 1
et je met
ShellExecute Me.hwnd, vbNullString, "C:\WINDOWS" + fic_ini , vbNullString, "C:", SW_SHOWNORMAL
dans mon géné, quand j'execute il me dit :
ERREUR de compilation :
Membre de methode ou de données introuvable