返回列表 上一主題 發帖

2個vba問題

本帖最後由 Hsieh 於 2010-8-7 23:45 編輯

回復 1# basarasy
  1. Sub NN()
  2. If IsNumeric(Application.Match(Split(ActivePrinter, " on")(0), Printer_List, 0)) Then
  3. ActiveSheet.PrintOut
  4. Else
  5. MsgBox "找不到印表機"
  6. End If
  7. End Sub
  8. Function Printer_List() As Variant
  9. '設定引用項目Microsoft Shell Controls And Automation
  10. Dim MySh As Shell32.Shell
  11. Dim MyPrinter As Shell32.FolderItem
  12. Dim Ar()
  13. Set MySh = CreateObject("Shell.Application")
  14. For Each MyPrinter In MySh.Namespace(ssfPRINTERS).Items
  15.   If MyPrinter.Name <> "新增印表機" Then
  16.      ReDim Preserve Ar(s)
  17.        Ar(s) = MyPrinter.Name
  18.        s = s + 1
  19.   End If
  20. Next
  21. Printer_List = Ar
  22. End Function
複製代碼
問題2應該是由Windows來控制可從API函數去找答案
學海無涯_不恥下問

TOP

執行NN看看
學海無涯_不恥下問

TOP

        靜思自在 : 屋寬不如心寬。
返回列表 上一主題