流星蔡园 发表于 2006-10-18 15:44:00

怎样按样式打印?

<P>我在编写一个批量的打印的程序,在程序中样式表已指定,但是下图中"按样式打印"怎么选中?有对应的系统变量吗?不选中的话批量打印时样式表起不了作用.</P>
<P>(图片截自AutoCAD的打印对话框)</P>

流星蔡园 发表于 2006-10-20 18:04:00

已解决

liushengk 发表于 2006-10-20 22:15:00

<P>怎么解决的?分享一下。</P>

流星蔡园 发表于 2006-10-21 12:38:00

<P>呵呵,其实一点技术含量都没有,一开始没发现</P>
<P>ThisDrawing.ModelSpace.Layout.PlotWithPlotStyles = True<BR></P>

weixin7944 发表于 2006-10-25 14:18:00

<P>最近,我也编了一个关于批处理的程序,但不知道为什么有时候可以运行,有时候就不可以!程序如下:</P>
<P>Private Sub cmdOk_Click()<BR>&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp; Dim ii As Integer<BR>&nbsp;&nbsp; Dim zz As Integer<BR>&nbsp;&nbsp; Dim drn As String<BR>&nbsp;&nbsp; Dim drn1 As String<BR>If lstFile.ListCount = 0 Then<BR>MsgBox "请添加所要操作的图形!"<BR>Exit Sub<BR>End If<BR>frmMain.hide<BR>For i = 0 To lstFile.ListCount - 1<BR>drn1 = lstFile.List(i)<BR>Application.Documents.Open drn1<BR>&nbsp;&nbsp;&nbsp; Dim ptmin(0 To 1) As Double: Dim ptmax(0 To 1) As Double<BR>ptmin(0) = -257: ptmin(1) = -271<BR>ptmax(0) = -1099: ptmax(1) = 324<BR>&nbsp;&nbsp;&nbsp; Dim currentPlot As AcadPlot<BR>&nbsp;&nbsp;&nbsp; Set currentPlot = ThisDrawing.Plot<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.SetWindowToPlot ptmin, ptmax<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.PlotType = acWindow<BR>&nbsp;&nbsp;&nbsp; If ComboBox1.Text = "ScaleToFit" Then<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StandardScale = acScaleToFit<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StandardScale = ac1_1<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveLayout.StyleSheet = TextBox2.Text<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentPlot.PlotToDevice TextBox1.Text<BR>&nbsp;&nbsp; Application.ActiveDocument.Close True, drn1<BR>Next i</P>
<P>End Sub</P>
<P>Private Sub cmdOpen_Click()<BR>&nbsp;&nbsp;&nbsp; On Error GoTo errHandle<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim Y As Integer<BR>&nbsp;&nbsp;&nbsp; Dim z As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FileNames() As String<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; With comDlg<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .CancelError = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .MaxFileSize = 32767<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .DialogTitle = "选择图形文件"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .filter = "图形文件(*.dwg)|*.dwg|所有文件(*.*)|*.*"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .FileName = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .ShowOpen<BR>&nbsp;&nbsp;&nbsp; End With<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; comDlg.FileName = comDlg.FileName &amp; Chr(0)&nbsp; '这些文件名是用空字符Chr(0)分隔符,而不是空格分隔符隔开<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; z = 1<BR>&nbsp;&nbsp;&nbsp; For i = 1 To Len(comDlg.FileName)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'InStr函数,返回 Variant (Long),指定一字符串在另一字符串中最先出现的位置。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '语法 InStr(起点位置, string1, string2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = InStr(z, comDlg.FileName, Chr(0))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If i = 0 Then Exit For<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReDim Preserve FileNames(Y)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Mid函数,返回 Variant (String),其中包含字符串中指定数量的字符。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '语法 Mid(string, start[, length])<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileNames(Y) = Mid(comDlg.FileName, z, i - z)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z = i + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y = Y + 1<BR>&nbsp;&nbsp;&nbsp; Next i</P>
<P>&nbsp;&nbsp;&nbsp; '向列表框中添加对象<BR>&nbsp;&nbsp;&nbsp; Dim count As Integer<BR>&nbsp;&nbsp;&nbsp; count = lstFile.ListCount<BR>&nbsp;&nbsp;&nbsp; If Y = 1 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lstFile.AddItem FileNames(count), 0<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 1 To Y - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileNames(i) = FileNames(0) &amp; "\" &amp; FileNames(i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lstFile.AddItem FileNames(i), i - 1 + count<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; End If<BR>errHandle:<BR>End Sub</P>

<P>Private Sub CommandButton1_Click()<BR>&nbsp;On Error GoTo errHandle<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim Y As Integer<BR>&nbsp;&nbsp;&nbsp; Dim z As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FileNames() As String<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; With comDlg<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .CancelError = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .MaxFileSize = 32767<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .DialogTitle = "选择PC3文件"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .filter = "数据文件(*.pc3)|*.pc3|所有文件(*.*)|*.*"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .FileName = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .ShowOpen<BR>&nbsp;&nbsp;&nbsp; End With<BR>&nbsp;&nbsp; TextBox1.Text = comDlg.FileName<BR>errHandle:<BR>End Sub</P>
<P>Private Sub CommandButton2_Click()<BR>On Error GoTo errHandle<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim Y As Integer<BR>&nbsp;&nbsp;&nbsp; Dim z As Integer<BR>&nbsp;&nbsp;&nbsp; Dim FileNames() As String<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; With comDlg<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .CancelError = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .MaxFileSize = 32767<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .DialogTitle = "选择CTB文件"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .filter = "数据文件(*.ctb)|*.ctb|所有文件(*.*)|*.*"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .FileName = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .ShowOpen<BR>&nbsp;&nbsp;&nbsp; End With<BR>&nbsp;&nbsp; TextBox2.Text = comDlg.FileName<BR>errHandle:<BR>End Sub</P>
<P>Private Sub UserForm_Initialize()<BR>&nbsp;&nbsp;&nbsp; lstFile.Clear<BR>&nbsp;&nbsp; ComboBox1.AddItem ("ScaleToFit")<BR>&nbsp;&nbsp;&nbsp; ComboBox1.AddItem ("1:1")<BR>&nbsp;&nbsp;&nbsp; End Sub<BR>出错提示为:Run-time error '_2154386493(80200003)'</P>
<P>Invalid input</P>
<P>不知道为什么,请高手分析一下,谢谢!</P>
页: [1]
查看完整版本: 怎样按样式打印?