- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 198
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-8-13
               
|
本帖最後由 Hsieh 於 2010-8-7 23:45 編輯
回復 1# basarasy - Sub NN()
- If IsNumeric(Application.Match(Split(ActivePrinter, " on")(0), Printer_List, 0)) Then
- ActiveSheet.PrintOut
- Else
- MsgBox "找不到印表機"
- End If
- End Sub
- Function Printer_List() As Variant
- '設定引用項目Microsoft Shell Controls And Automation
- Dim MySh As Shell32.Shell
- Dim MyPrinter As Shell32.FolderItem
- Dim Ar()
- Set MySh = CreateObject("Shell.Application")
- For Each MyPrinter In MySh.Namespace(ssfPRINTERS).Items
- If MyPrinter.Name <> "新增印表機" Then
- ReDim Preserve Ar(s)
- Ar(s) = MyPrinter.Name
- s = s + 1
- End If
- Next
- Printer_List = Ar
- End Function
複製代碼 問題2應該是由Windows來控制可從API函數去找答案 |
|