sanjie 发表于 2005-11-24 18:02:00

如何用VBA批量更换打印模型中的打印机名称?

本帖最后由 作者 于 2005-12-1 19:43:28 编辑 <br /><br /> <FONT face=宋体 size=2>我有很多的CAD图纸,用的都是HP LaserJet 8100 Series PCL的打印机,现在打印机换成了HP LaserJet 5100 PCL 6,该如何用VBA批量把D:\cad\下图纸的打印机由HP LaserJet 8100 Series PCL更改为HP LaserJet 5100 PCL 6,我不想手动一个个修改了,请高手解决!</FONT>

sanjie 发表于 2005-11-26 14:54:00

我知道用VBA for Excel可以!相信用CAD也可以!请高手解答!

sanjie 发表于 2005-12-1 19:40:00

我可以用以下代码批量打开Excel,但不知该如何批量打开CAD,
Sub xiugai()
Application.ScreenUpdating = False
With Application.FileSearch
.LookIn = "D:\new"
.FileType = msoFileTypeExcelWorkbooks
.SearchSubFolders = True
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open Filename:=.FoundFiles(i)
Worksheets("10KV1").Select
Range("D65").Value = 0
Range("D66").Value = 0
Range("D67").Value = 0
Range("D78").Value = 0
Range("D79").Value = 0
Range("D133").Value = 0
ActiveWorkbook.Close savechanges:=True
Next i
Else
MsgBox "没有找到任何工作簿文件"
End If
End With
Application.ScreenUpdating = True
End Sub

sanjie 发表于 2006-2-10 14:48:00

论坛这么冷清...............

alin 发表于 2006-2-14 11:45:00

;; The following code change the default modelspace printer
;; for all the drawings in the path "H:\" to "DWF6 ePlot.pc3"
;; Author: UnknownOption Explicit
Sub BatchChangePrinter()
Dim files() As String
Dim file_name As String
Dim dir_path As String
Dim num_files, a As Long
dir_path = "H:\*.dwg"
file_name = Dir$(dir_path)
Do While Len(file_name) > 0
    If Not (file_name = ".") Or (file_name = "..") Then
      num_files = num_files + 1
      ReDim Preserve files(1 To num_files)
      files(num_files) = Left(dir_path, Len(dir_path) - 5) & file_name
    End If
    file_name = Dir$()
Loop
For a = LBound(files) To UBound(files)
    Dim doc As AcadDocument
    Dim model As AcadLayout
   Set doc = ThisDrawing.Application.Documents.Open(files(a))
   Set model = doc.Layouts("Model")
   model.RefreshPlotDeviceInfo
   model.ConfigName = "DWF6 ePlot.pc3"
   doc.Close (True)
Next
End Sub

mccad 发表于 2006-2-14 12:29:00

<A href="http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=669" target="_blank" >http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=669</A>
页: [1]
查看完整版本: 如何用VBA批量更换打印模型中的打印机名称?