# VBA Code to print Solid Edge .DFT drawings



## darkrid3r (Jun 1, 2012)

Hi,

i would really like to be able to print a serie of .dft files with a list generated in excel.

I've search over the web and found two sites that might help but i am far from being able to do anything with it since I never worked with framework stuff.

Here are the two sites :

This guy said the code worked to print just like i want, but it doesn't work for me (getting an error at Dim objApp As SolidEdgeFramework.Application User-defined type not defined)

http://www.jasonnewell.net/forums/solid-edge-programming/556-printing-a-dft-using-vba-in-excel.html

And the second site contains Framework stuff, which i don't quite understand to be really honest.

http://www.codeproject.com/Articles/33576/Solid-Edge-ST-Addins-Part-I

Thanks a lot in advance.


----------



## darkrid3r (Mar 5, 2014)

Hi,

I still have a problem with my code. I use this code to print in PDF all my dft. I would like the code to update the DFT if needed, because sometimes they are not. I tried solidedgedraft.DrawingView.Update and solidedgedraft.DrawingView.forceUpdate but it didn't work.


```
Sub PrintDraft()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As solidedgedraft.DraftDocument
Dim objSheet As solidedgedraft.Sheet

Dim FilePath_VA As String
Dim PrinterName_VA As String
Dim SEprinter_VA As String
Dim x As Integer
Dim message As String

message = "Please Wait - Opération en cours"


Application.StatusBar = message

PrinterName_VA = Application.ActivePrinter
SEprinter_VA = GetDefaultPrinterName

On Error Resume Next

Set objApp = GetObject(, "SolidEdge.Application")

If Err Then
Err.Clear

    Set objApp = CreateObject("SolidEdge.Application")
    objApp.DisplayAlerts = False
    
    If Worksheets("Print List").Range("Q1").Value > 0 Then

        For x = Worksheets("Print List").Range("Q1").Value To Worksheets("Print List").Range("R1").Value
        Application.StatusBar = message & "."
        If Worksheets("Print List").Range("P" & x).Value <> "" Then

            FilePath_VA = Worksheets("Print List").Range("P" & x).Value
        
            Set objDoc = objApp.Documents.Open(FilePath_VA)
        

            objApp.Visible = True
            
            
            solidedgedraft.DrawingView.Update
            solidedgedraft.DrawingView.ForceUpdate
            ' Find the default printer using the API
            
            objDoc.PrintOut SEprinter_VA, Orientation:=2
            Call objDoc.Close
        
        End If
    
        Next
    
    End If
    

End If
Application.StatusBar = False
Call objApp.Quit

Set objApp = Nothing
Set objDoc = Nothing
Set objSheet = Nothing

End Sub
```

Thanks


----------

