返回列表 上一主題 發帖

2個vba問題

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

TOP

回復 2# Hsieh

謝謝大大
但不知放在那裡><

可以這樣寫嗎?
Sheet2.Select
if  找不到列印機 then
msgbox 沒有列印機
end
else
ActiveSheet.PrintOut from:=1, To:=1, copies:=1

紅色那句我不知如何寫><
50 字節以內
不支持自定義 Discuz! 代碼

TOP

本帖最後由 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

        靜思自在 : 口說好話、心想好意、身行好事。
返回列表 上一主題