# 查看完整版本 : Excel Marco 問題求大神指導

thendless 2019-12-30 08:39 PM

## Excel Marco 問題求大神指導

Sheets("Main").Select
Rows("11:23").Select
Selection.Copy
Sheets("Record").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Sheets("Main").Select
Range("B7").Select
Application.CutCopyMode = False
Range("C6").Select
Selection.ClearContents
oldprinter = Application.ActivePrinter

For i = 0 To 25
curNePrint = Format(i, "00")
On Error Resume Next
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":"
Next i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Application.ActivePrinter = oldprinter
ActiveCell.FormulaR1C1 = "Printed!"
Range("C6").Select
With Selection.Font
.Color = -11489280
End With
Range("D6").Select

End Sub

alee001 2019-12-31 10:32 AM

Printer名稱可能不同
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":"

thendless 2019-12-31 01:05 PM

[quote]原帖由 [i]alee001[/i] 於 2019-12-31 10:32 AM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=512435914&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
Printer名稱可能不同
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":" [/quote]

alee001 2019-12-31 03:19 PM

thendless 2019-12-31 03:36 PM

[quote]原帖由 [i]alee001[/i] 於 2019-12-31 03:19 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=512448538&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

For i = 0 To 25
curNePrint = Format(i, "00")
On Error Resume Next
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":"
Next i

[quote]原帖由 [i]thendless[/i] 於 2019-12-31 03:36 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=512449489&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

For i = 0 To 25
curNePrint = Format(i, "00")
On Error Resume Next
Applicatio ... [/quote]on error resume next 呢句野唔應該濫用。既然你 printing 時得時唔得，你應該 print 個 error code description 睇下咩事。

For i = 0 To 25
curNePrint = Format(i, "00")
On Error  goto errHandler
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":"
errHandler:
if err.number <> 0 then
msgbox(Err.Description)
end if
Next i

thendless 2020-1-2 03:13 PM

" [quote]原帖由 [i]煙民母親生賤種[/i] 於 2020-1-1 01:51 AM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=512471945&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
on error resume next 呢句野唔應該濫用。既然你 printing 時得時唔得，你應該 print 個 error code description 睇下咩事。

For i = 0 To 25
curNePrint = Format(i, "00")
On Error  goto errHandler
Applicati ... [/quote]

xianrenb 2020-1-2 07:11 PM

[quote]原帖由 [i]thendless[/i] 於 2019-12-30 08:39 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=512418398&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

Sheets("Main").Select
... [/quote]

[quote]原帖由 [i]thendless[/i] 於 2020-1-2 03:13 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=512535723&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
"

alee001 2020-1-4 09:08 PM

howevera 2020-1-10 01:51 PM

For i = 0 To 25
curNePrint = Format(i, "00")
On Error Resume Next
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":"
If Err.Number = 0 Then Exit For
Next i

ncream 2020-1-17 10:19 AM

Nexx，部部電腦都唔同。

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices

[attach]10748509[/attach]

[[i] 本帖最後由 ncream 於 2020-1-17 10:26 AM 編輯 [/i]]

darigold 2020-1-18 12:48 AM

Sigh

[quote]原帖由 [i]darigold[/i] 於 2020-1-18 12:48 AM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=513178502&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
Sigh

:fst_004::fst_004::fst_004:

thendless 2020-1-23 04:26 PM

[quote]原帖由 [i]ncream[/i] 於 2020-1-17 10:19 AM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=513148605&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
Nexx，部部電腦都唔同。

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices

10748509

ncream師兄, 我可以好似你咁講入到去你講既位置搵到個printer. 但可唔可以講得detail d我應該點寫? 其實我唔係做呢行, 我都唔係好識寫呢d, 初級班黎lol.

oldprinter = Application.ActivePrinter

For i = 0 To 99
curNePrint = Format(i, "00")
On Error Resume Next
Application.ActivePrinter = "\\hk-print01\HKHK_Printer15 on ne" & curNePrint & ":"
Next i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Application.ActivePrinter = oldprinter

ncream 2020-1-23 11:09 PM

[quote]原帖由 [i]thendless[/i] 於 2020-1-23 04:26 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=513395778&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

ncream師兄, 我可以好似你咁講入到去你講既位置搵到個prin ... [/quote]

[attach]10770621[/attach]

[attach]10770622[/attach]

FILE:

[url=https://www.sendspace.com/file/kvk4z7]https://www.sendspace.com/file/kvk4z7[/url]

[[i] 本帖最後由 ncream 於 2020-1-24 12:15 PM 編輯 [/i]]

thendless 2020-1-24 12:28 PM

[quote]原帖由 [i]ncream[/i] 於 2020-1-23 11:09 PM 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=513408028&ptid=28788580][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]

10770621

10770622

FILE:

[url=https://www.sendspace.com/file/kvk4z7]https://www.sendspace.com/file/kvk4z7[/url]