lecknaat | Pas de probleme...
Code :
- Imports System.IO
- Imports System.Drawing.Printing.PaperSize
- Imports System.Drawing.Printing
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- '---Il faut que Solid Edge soit lancé---
- Try
- objApp = GetObject(, "SolidEdge.Application" )
- Catch ex As Exception
- MessageBox.Show("Solid Edge doit tourner", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
- System.Threading.Thread.CurrentThread.Abort()
- End Try
- '---------------------------------------
- '---Il faut que le document ouvert soit un draft---
- Try
- objDoc = objApp.ActiveDocument
- Catch ex As Exception
- MessageBox.Show("Le fichier ouvert doit être un draft", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
- System.Threading.Thread.CurrentThread.Abort()
- End Try
- '--------------------------------------------------
- Nom = Microsoft.VisualBasic.Left(objDoc.Name, objDoc.Name.Length - 4)
- '----------------------
- '---Revision manager---
- '----------------------
- Try
- DoWorkRM(StartRevisionManager())
- Catch ex As Exception
- MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- objAppGR = GetObject(, "RevisionManager.Application" )
- Try
- objDocGR = objAppGR.Open(objDoc.FullName, 2)
- Catch ex As Exception
- MessageBox.Show("Sauvegarder le document et relancer la macro", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
- System.Threading.Thread.CurrentThread.Abort()
- End Try
- objDocGR = objAppGR.Open(objDoc.FullName, 2)
- objLinkedDocs = objDocGR.LinkedDocuments(RevisionManager.LinkTypeConstants.seLinkTypeAll)
- If objLinkedDocs.Count <> 0 Then
- objLinkedDoc = objLinkedDocs.Item(1)
- Dim extension As String
- extension = Microsoft.VisualBasic.Right(objLinkedDoc.FullName, 3)
- Select Case extension
- Case "par", "PAR", "Par", "psm", "PSM", "Psm", "pwd", "PWD", "Pwd", "asm", "ASM", "Asm"
- Dim objProperties As SolidEdgeFileProperties.PropertySets
- Try
- objProperties = CreateObject("SolidEdge.FileProperties" )
- Catch ex As Exception
- MessageBox.Show(objLinkedDoc.FullName & " ne peut être ouvert", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
- Exit Select
- End Try
- Try
- objProperties.Open(objLinkedDoc.FullName, True)
- Catch ex As Exception
- MessageBox.Show(objLinkedDoc.FullName & " ne peut être ouvert", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
- Exit Select
- End Try
- Numero = objLinkedDoc.DocNum
- Revision = objLinkedDoc.Revision
-
- Case Else
- MsgBox(objLinkedDoc.FullName & " : type de fichier non traité", MsgBoxStyle.Exclamation)
- End Select
- End If
- '----------------------
- Nom_final = (Numero + "~" + Revision + " " + Nom)
- 'MsgBox(Nom_final)
- Dossier = objDoc.Path
- Dim Orientation As Integer
- 'Dim Size As SolidEdgeDraft.PaperSizeConstants
- Dim Size As Object
- objsheet = objDoc.ActiveSheet
- taille = objsheet.SheetSetup.SheetSizeOption
- Dim A0 As New PaperSize("A0", PrinterUnitConvert.Convert(84100, PrinterUnit.HundredthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(118900, PrinterUnit.HundredthsOfAMillimeter, PrinterUnit.Display))
- Dim A0R As New PaperSize("A0R", 1189, 841)
- Dim A1 As New PaperSize("A1", 594, 841)
- Dim A1R As New PaperSize("A1R", 841, 594)
- Select Case taille
- Case 36
- Orientation = 1
- Size = A0.Kind
- Case 37
- Orientation = 2
- Size = A0R.Kind
- Case 34
- Orientation = 1
- Size = A1.Kind
- Case 35
- Orientation = 2
- Size = A1R.Kind
- Case 32
- Orientation = 1
- Size = Printing.PaperKind.A2
- Case 33
- Orientation = 2
- Size = Printing.PaperKind.A2
- Case 30
- Orientation = 1
- Size = Printing.PaperKind.A3
- Case 31
- Orientation = 2
- Size = Printing.PaperKind.A3
- Case 28
- Orientation = 1
- Size = Printing.PaperKind.A4
- End Select
- objDoc.SaveAs(("C:\WINDOWS\Temp\" + Nom_final + ".dft" ))
- objDoc.PrintOut("PDF995", 1, , Size, , False)
- ''File.Copy(("C:\WINDOWS\Temp\" + Nom_final + ".pdf" ), (Dossier + "\" + Nom_final + ".pdf" ))
- ''File.Delete(("C:\WINDOWS\Temp\" + Nom_final + ".pdf" ))
- 'File.Delete(("C:\WINDOWS\Temp\" + Nom_final + ".dft" ))
- Me.Close()
- '---Fermeture
- objApp = Nothing
- objProp = Nothing
- objDoc = Nothing
- objProperties = Nothing
- objsheet = Nothing
- taille = Nothing
- End Sub
- End Class
|
|