PDA

View Full Version : Setting Printing Path Problem


kyheulon
03-02-2006, 05:15 PM
Everyone,

I have created a VBA that sets the printing config paths (plotter, plot style...) and the application works and sets the paths correctly. The problem is even with the paths set correctly the plots and preview doesn't print or look correctly. It's like the pen table isn't being used where the plot should be all black it plots in degrees of gray. He is the kicker... to "fix" the problem I can simply open and Cancel the Opions dialog box without changing a thing, and the print or preview works perfect. Second, the "fix" works until I restart AutoCAD. We're using AutoCAD 2006, but had the same problem with 04.

I'm pretty new to VBA so please be detailed if you can help.

Thanks, Keith

Eddie
06-02-2006, 02:31 AM
It would help if posted your code so we can see where it may need tweeking....
Don't forget to use these --> [ code]Your code goes in here[/code ]

kyheulon
06-02-2006, 12:32 PM
Here is the code I'm using....
[ code]
Private Sub AcadDocument_Activate()

Dim AcadPrefFiles As AcadPreferencesFiles
Dim Layout As AcadLayout
Dim strDefaultPath As String
Dim strDrawingPath As String
Dim strDrawingPathChar As String
Dim strProjCadd As String
Dim strPrinterPath As String
Dim varCounter As Variant
Dim varPathLen As Variant
Dim fso

Set AcadPrefFiles = ThisDrawing.Application.preferences.Files
Set Layout = ThisDrawing.ActiveLayout
strDefaultPath = "Q:\AutoCAD 2006\General\Plotting"
strDrawingPath = ThisDrawing.Path & "\"
strProjCadd = "ProjectCadd\Plotting"
varCounter = Len(strDrawingPath)
Set fso = CreateObject("Scripting.FileSystemObject")

Do While varCounter > 0

strDrawingPath = Left(strDrawingPath, varCounter)
strDrawingPathChar = Right(strDrawingPath, 1)
varCounter = varCounter - 1

If varCounter = 0 Then
AcadPrefFiles.PrinterStyleSheetPath = strDefaultPath
AcadPrefFiles.PrinterConfigPath = strDefaultPath
AcadPrefFiles.PrinterDescPath = strDefaultPath
ElseIf strDrawingPathChar = "\" Then
strPrinterPath = strDrawingPath & strProjCadd
If fso.FolderExists(strPrinterPath) Then
AcadPrefFiles.PrinterStyleSheetPath = strPrinterPath
AcadPrefFiles.PrinterConfigPath = strPrinterPath
AcadPrefFiles.PrinterDescPath = strPrinterPath
varCounter = 0
End If
End If

Loop

Layout.RefreshPlotDeviceInfo

End Sub

[/code ]