Jump to content

Recommended Posts

Posted

Perhaps someone here could come up with an explanation because I am stumped. I this program on a list of DWG files on two different computers, with the same printer setups.

 

However, on one computer the entire program (below is just the problem procedure), prints out each drawing correctly as a .plt file. I then copy the files to a server distiller running Adobe Distiller 6.0.

 

I then try to test it on another computer verifying the settings and the DWG files are the same and at first the program runs fine. It prints out the first DWG file as a .plt and starts on the second. I then receive the following error: "Method 'PlotToFile' of object 'IAcadPlot' fail". I then click Debug and this line highlights (the last line of the procedure):

 

Application.ActiveDocument.Plot.PlotToFile ("C:\distill\" & strFileName)

 

I know you have to trust me on this one; but I have toggled breakpoints and watched the variables and they are all set correctly when it gets to that point.

 

There are, at least, two differences with the two computers, which I believe might be causing an error. First, the computer that is having trouble is slower; but I doubt this is the case since is a single VBA project and only calls a LISP function (with the SendCommand) once in another procedure. Second, the problem computer does have Adobe Distiller 8 installed and even though it never comes up, in this case, if I was to plot a DWG manually the distiller will automatically convert the .plt file to a PDF.

 

Anyways, I know this is an essay of a post; but I am really stumped and am looking for any reasons as to way this program will run on 1 computer just fine and get stuck on another.

 

Any ideas or problems with the code? I hope someone more experienced in VBA could see something.

 

Here is the problem procedure:

 

 

Sub PDFPrint(strPlotSize As String, strFileName As String)
   ' Declare Local Variables
   Dim dblLowerLeft(0 To 1) As Double
   Dim dblUpperRight(0 To 1) As Double
   Dim dblNum As Double ' Reserved for "."SetCustomScale" option
   Dim dblDen As Double ' Reserved for "."SetCustomScale" option
   Dim strPaperSize As String
   Dim strStyleSheet As String
   Dim psPageSetup As AcadPlotConfiguration

   ' Get the Upper Right Point of the Window defined from LISP routine
   dblUpperRight(0) = Application.ActiveDocument.GetVariable("USERR1")
   dblUpperRight(1) = Application.ActiveDocument.GetVariable("USERR2")

   ' Get the Lower Left Point of the Window defined from LISP routine
   dblLowerLeft(0) = Application.ActiveDocument.GetVariable("USERR3")
   dblLowerLeft(1) = Application.ActiveDocument.GetVariable("USERR4")

   ' Get File Name for plt File Save
   strFileName = Application.ActiveDocument.Name
   strFileName = Left(strFileName, Len(strFileName) - 4)

    ' Reserved for Debugging - Do we have proper Print Area
'    MsgBox "Lower Left Point: " & dblLowerLeft(0) & " x " & dblLowerLeft(1) & vbCr & _
'           "Upper Right Point: " & dblUpperRight(0) & " x " & dblUpperRight(1)

   If (strPlotSize = "Postscript_F") Then 
       ' Set Landscape Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Landscape")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "User124" ' This is for "ANSI F" of the Adobe Printer
       strStyleSheet = "monochrome.ctb"
       dblNum = 28 ' Reserved for "."SetCustomScale" option

   ElseIf (strPlotSize = "Postscript_F_color") Then

       ' Set Landscape Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Landscape")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "User124" ' This is for "ANSI F" of the Adobe Printer
       strStyleSheet = "acad.ctb"
       dblNum = 28 ' Reserved for "."SetCustomScale" option

   ElseIf (strPlotSize = "Postscript_E") Then

       ' Set Landscape Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Landscape")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "User123" ' This is for "ANSI E" of the Adobe Printer
       strStyleSheet = "monochrome.ctb"

   ElseIf (strPlotSize = "Postscript_D") Then

       ' Set Landscape Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Landscape")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "User122" ' This is for "ANSI D" of the Adobe Printer
       strStyleSheet = "monochrome.ctb"

   ElseIf (strPlotSize = "Postscript_B") Then

       If (blkName = "BGSE") Then
           dblLowerLeft(0) = dblLowerLeft(0) + 0.668307
       End If

       ' Set Landscape Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Landscape")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "User119" ' "11x17" ' This is for "11x17" of the Adobe Printer
       strStyleSheet = "monochrome.ctb"
       dblNum = 10.563 ' Reserved for "."SetCustomScale" option

   ElseIf (strPlotSize = "Postscript_A") Then

       ' Set Portrait Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Portrait")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "Letter" ' This is for "Letter" of the Adobe Printer
       strStyleSheet = "monochrome.ctb"
       dblNum = 10.6981 ' Reserved for "."SetCustomScale" option

   ElseIf (strPlotSize = "Postscript_A_land") Then

       ' Set Landscape Mode
       Set psPageSetup = Application.ActiveDocument.PlotConfigurations.Add("BatchPrint_Landscape")

       ' Copy Selected Page Setups
       Application.ActiveDocument.ActiveLayout.CopyFrom psPageSetup

       ' Define Page Specific Properties
       strPrinter = "Adobe PDF.pc3"
       strPaperSize = "Letter" ' This is for "Letter" of the Adobe Printer
       strStyleSheet = "monochrome.ctb"
       dblNum = 8.3125 ' Reserved for "."SetCustomScale" option

   End If

   With Application.ActiveDocument.ModelSpace.layout ' Application.ActiveDocument.ActiveLayout
       .ConfigName = strPrinter
       .StyleSheet = strStyleSheet
       .CenterPlot = True
'        .SetCustomScale dblNum, dblUpperRight(1) ' Reserved for Future Expansion
       .StandardScale = ac1_1
       .ScaleLineweights = True
       .SetWindowToPlot dblLowerLeft, dblUpperRight
       .GetWindowToPlot dblLowerLeft, dblUpperRight
       .PlotType = acWindow
       .CanonicalMediaName = strPaperSize
       .RefreshPlotDeviceInfo
   End With

'    Application.ActiveDocument.Plot.DisplayPlotPreview acFullPreview ' Reserved for Debugging
   Application.ActiveDocument.Plot.PlotToFile ("C:\distill\" & strFileName)

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...