Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Workbook_Open()
- 'Ouverture du fichier NC
- WBXLS = ActiveWorkbook.Name
- ChDrive "D:\"
- ChDir "D:\Bureau"
- a = Application.GetOpenFilename("NCFiles (*.NC), *.NC")
- Select Case TypeName(a)
- Case Is = "Boolean"
- Exit Sub
- Case Else
- Workbooks.OpenText Filename:=a, Origin:=xlMSDOS, _
- StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
- ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
- , Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
- TrailingMinusNumbers:=True
- End Select
- WBNC = ActiveWorkbook.Name
- 'Modif des données
- i = 1 'init ligne 1
- FR = 0
- Do While Not Cells(i, 1).Value Like "M30"
- Cells(i, 1).Select
- If Cells(i, 1).Value Like "G28 U0 V0 W0" Then
- Cells(i, 1).Value = "G28 U0 W0"
- ElseIf Cells(i, 1).Value Like "T????" Then
- Cells(i, 1).Value = Cells(i, 1).Value & " M41"
- Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
- Cells(i, 1).Value = "M69"
- i = i + 1
- ElseIf Cells(i, 1).Value Like "*M97*" Then
- FR = 1
- ElseIf Cells(i, 1).Value Like "*G49*" Then
- Rows(i).Delete Shift:=xlUp
- i = i - 1
- End If
- i = i + 1
- Loop
- If FR = 1 Then
- MsgBox ("M97 détecté, verifier que le M69 ajouté à l'appel d'outil ne doit pas être supprimé ou rebloquer le mandrin après")
- End If
- Debug.Print (WBXLS)
- Debug.Print (WBNC)
- Debug.Print ("--------")
- XLClose = 1
- For Each WB In Application.Workbooks
- Debug.Print (WB.Name)
- If WB.Name <> WBXLS And WB.Name <> WBNC Then
- Debug.Print ("No Match")
- XLClose = 0
- End If
- Next WB
- Application.DisplayAlerts = False
- Workbooks(WBNC).SaveAs a
- If XLClose = 1 Then
- Application.Quit
- Else
- Workbooks(WBNC).Close
- Workbooks(WBXLS).Close
- End If
- End Sub
Add Comment
Please, Sign In to add comment