关于网络打印机的问题
<p>最近我用VBA设计了一个批打印程序,遇到了一个问题:我使用的是局域网的打印机,其它的设置如打印机选择、打印方向、打印比表等都已经设计好了,并运行正确。但是,我不知道怎样选择网络打印机的纸张。在所有的纸张列表中就只有CAD默认的纸张列表(没有A3和A4),选择不了网络打印机的纸张列表,程序如下,请高手指点一下,怎样选择网络打印机的纸张。</p><p>Private Sub cmdCancel_Click()<br/> End<br/>End Sub</p><p>Private Sub cmdDelete_Click()<br/> '确认列表框包含列表项<br/> If lstFile.ListCount >= 1 Then<br/> '如果没有选中的内容,用上一次的列表项。<br/> If lstFile.ListIndex = -1 Then<br/> MsgBox "请选择列表中的图形名称!"<br/> Exit Sub<br/> End If<br/> lstFile.RemoveItem (lstFile.ListIndex)<br/> End If</p><p>End Sub</p><p>Private Sub cmdOk_Click()<br/> Dim i As Integer<br/> Dim ii As Integer<br/> Dim zz As Integer<br/> Dim drn As String<br/> Dim drn1 As String<br/>If lstFile.ListCount = 0 Then<br/>MsgBox "请添加所要操作的图形!"<br/>Exit Sub<br/>End If<br/> If ComboBox1.Text = "" Then<br/> MsgBox "请添加所要操作的图形!"<br/> End If<br/> Select Case (ComboBox1.Text)<br/> Case Is = "HP-0"<br/> AAPRINTER = "<a href="file://\\Plotter3\hp-0">\\Plotter3\hp-0</a>"<br/> Case Is = "HP-1"<br/> AAPRINTER = "<a href="file://\\Plotter3\hp-1">\\Plotter3\hp-1</a>"<br/> Case Is = "HP-3"<br/> AAPRINTER = "<a href="file://\\Plotter3\hp-3">\\Plotter3\hp-3</a>"<br/> Case Is = "HP-4"<br/> AAPRINTER = "<a href="file://\\Plotter4\hp-4">\\Plotter4\hp-4</a>"<br/> End Select<br/>drn2 = TextBox2.Text<br/>zz = 1<br/> For ii = 1 To Len(drn2)<br/> ii = InStr(zz, drn2, Chr(92))<br/> If ii = 0 Then Exit For<br/> zz = ii + 1<br/> Next ii<br/> drn = Mid(drn2, zz)<br/>frmMain.hide<br/>For i = 0 To lstFile.ListCount - 1<br/>drn1 = lstFile.List(i)<br/>Application.Documents.Open drn1<br/>ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo<br/> Dim currentPlot As AcadPlot<br/> Set currentPlot = ThisDrawing.Plot<br/> ThisDrawing.ActiveLayout.PlotType = acExtents<br/> ThisDrawing.ActiveLayout.StandardScale = acScaleToFit<br/> ThisDrawing.ActiveLayout.StyleSheet = drn<br/> ThisDrawing.ActiveLayout.PlotRotation = ac90degrees<br/> ThisDrawing.ActiveLayout.CanonicalMediaName = ComboBox2.Text<br/> currentPlot.PlotToDevice AAPRINTER<br/> Application.ActiveDocument.Close False, drn1<br/>Next i</p><p>End Sub</p><p>Private Sub cmdOpen_Click()<br/> On Error GoTo errHandle<br/> <br/> Dim i As Integer<br/> Dim Y As Integer<br/> Dim z As Integer<br/> Dim FileNames() As String<br/> <br/> With comDlg<br/> .CancelError = True<br/> .MaxFileSize = 32767<br/> .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks<br/> .DialogTitle = "选择图形文件"<br/> .filter = "图形文件(*.dwg)|*.dwg|所有文件(*.*)|*.*"<br/> .FileName = ""<br/> .ShowOpen<br/> End With<br/> <br/> comDlg.FileName = comDlg.FileName & Chr(0) '这些文件名是用空字符Chr(0)分隔符,而不是空格分隔符隔开<br/> <br/> z = 1<br/> For i = 1 To Len(comDlg.FileName)<br/> 'InStr函数,返回 Variant (Long),指定一字符串在另一字符串中最先出现的位置。<br/> '语法 InStr(起点位置, string1, string2)<br/> i = InStr(z, comDlg.FileName, Chr(0))<br/> If i = 0 Then Exit For<br/> ReDim Preserve FileNames(Y)<br/> 'Mid函数,返回 Variant (String),其中包含字符串中指定数量的字符。<br/> '语法 Mid(string, start[, length])<br/> FileNames(Y) = Mid(comDlg.FileName, z, i - z)<br/> z = i + 1<br/> Y = Y + 1<br/> Next i</p><p> '向列表框中添加对象<br/> Dim count As Integer<br/> count = lstFile.ListCount<br/> If Y = 1 Then<br/> lstFile.AddItem FileNames(count), 0<br/> Else<br/> For i = 1 To Y - 1<br/> FileNames(i) = FileNames(0) & "\" & FileNames(i)<br/> lstFile.AddItem FileNames(i), i - 1 + count<br/> Next i<br/> End If<br/>errHandle:<br/>End Sub</p><p></p><p></p><p>Private Sub CommandButton2_Click()<br/>On Error GoTo errHandle<br/> <br/> Dim i As Integer<br/> Dim Y As Integer<br/> Dim z As Integer<br/> Dim FileNames() As String<br/> <br/> With comDlg<br/> .CancelError = True<br/> .MaxFileSize = 32767<br/> .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks<br/> .DialogTitle = "选择CTB文件"<br/> .filter = "数据文件(*.ctb)|*.ctb|所有文件(*.*)|*.*"<br/> .FileName = ""<br/> .ShowOpen<br/> End With<br/> TextBox2.Text = comDlg.FileName<br/>errHandle:<br/>End Sub</p><p><br/>Private Sub UserForm_Initialize()<br/> lstFile.Clear<br/> ComboBox1.AddItem ("HP-0")<br/> ComboBox1.AddItem ("HP-1")<br/> ComboBox1.AddItem ("HP-3")<br/> ComboBox1.AddItem ("HP-4")<br/> ComboBox2.AddItem ("A3")<br/> ComboBox2.AddItem ("A4")<br/> End Sub<br/></p>
页:
[1]