|
给你做了些简化,还是睡觉了,没有细细去看不知道符合效果否
窗体部分- Private Sub Combo75_AfterUpdate()
- Call DefaultPrinter(Me.Combo75.Text)
- End Sub
- Private Sub Form_Open(Cancel As Integer)
- Me.Combo75.RowSourceType = "Value List"
- Me.Combo75.RowSource = GetPrinters
- Me.Combo75 = prtDefaultIndex
- End Sub
复制代码 模块部分- Public prtDefaultIndex As Long
- Public Function DefaultPrinter(PrinterName)
- Dim Ofs As IWshNetwork_Class
- Set Ofs = New IWshNetwork_Class
- Ofs.SetDefaultPrinter (PrinterName)
- DefaultPrinter = True
- End Function
- Public Function GetPrinters() As String
- Dim i As Integer
-
- For i = 0 To Application.Printers.Count - 1
- GetPrinters = GetPrinters & ";" & i & "," & Application.Printers(i).DeviceName
-
- If Application.Printer.DeviceName = Application.Printers(i).DeviceName Then
- prtDefaultIndex = i
- End If
-
- Next i
- GetPrinters = Mid(GetPrinters, 2)
- End Function
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|