VBA и принтер
26 отговора
332 прегледа
VBA и принтер
Знае ли някой дали и как може с VBA принтера да се настрои от autоmatic на manual printing? Направил съм един макрос, който печата едни бланки от двете страни на листа: първо печата нечетните страници, после отивам до принтера, обръщам отпечатаните листова на обратно и пускам четните. Обаче ако някой ме изпревари да печата нещо друго на принтера ще ми развали бланките. За това искам след като се отпечатат нечетните, принтера да преминава в manul режим, и след като отида до принтера да обърна листовете и да натина бутона на принтера, за да отпечата и останалата част, и чак след това да е свободен за другите компютри от мрежата.
Някой може ли да помогне, в стандартните команди няма такава функиця
, а и така ще си спестя едно разкарване до принтера
Някой може ли да помогне, в стандартните команди няма такава функиця
Редактирано от Fast Taker на
Re: VBA и принтер
Не можах да разбера точно как си го направил и колко процедури имаш, но видях в хелпа синтаксиса на PRINT
Syntax
PRINT(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
PRINT?(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
Там има feed. То може да е manual. Не ти върши работа, като пуснеш само първото четно на manual?
Syntax
PRINT(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
PRINT?(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
Там има feed. То може да е manual. Не ти върши работа, като пуснеш само първото четно на manual?
Re: VBA и принтер
Много пъти съм търсил в хелпа, но PRINT не съм намирал, има само PrintOut.
Как мога да използвам тази команда, дава ми грешка Object doesn't support this property or method (Error 438), като напиша:
ThisWorkbook.Sheets("DC" & 1).Print?
Как мога да използвам тази команда, дава ми грешка Object doesn't support this property or method (Error 438), като напиша:
ThisWorkbook.Sheets("DC" & 1).Print?
Re: VBA и принтер
аз също не мога да го намеря в Help-а, може ли да дадеш някакъв пример, за да ни стане по ясно
Електронни таблици
Електронни таблици
Re: VBA и принтер
PRINT
Macro Sheets Only
Equivalent to choosing the Print command from the File menu. Prints the active workbook.
Arguments correspond to options, check boxes, and edit boxes in the Print dialog box. Arguments corresponding to check boxes are logical values. If an argument is TRUE, Microsoft Excel selects the check box; if FALSE, Microsoft Excel clears the check box.
Syntax
PRINT(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
PRINT?(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
Range_num is a number specifying which pages to print.
Range_num Prints the following pages
1 All the pages
2 Prints a specified range. If range_num is 2, then from and to are required arguments.
From specifies the first page to print. This argument is ignored unless range_num equals 2.
To specifies the last page to print. This argument is ignored unless range_num equals 2.
Copies specifies the number of copies to print. If omitted, the default is 1.
Draft This argument overrides the draft argument from the PAGE.SETUP function. If omitted, the Draft Setting from the Page.Setup function is used.
Preview is a logical value corresponding to the Print Preview button in the Print dialog box. If TRUE, the print preview window will be displayed. If FALSE, the window will not be displayed
Print_what is a number from 1 to 3 that specifies what parts of the sheet or macro sheet to print. If a chart is active, print_what is ignored. This argument will override the setting in the Page Setup dialog box. If omitted, the note argument in the Page.Setup function is used to determine whether to print notes or not.
Print_what Prints
1 Sheet only
2 Notes only
3 Sheet and then notes
Color corresponds to the Print Using Color check box. Color is available only in Microsoft Excel for the Macintosh. If omitted, the setting is not changed.
Feed is a number specifying the type of paper feed. Feed is available only in Microsoft Excel for the Macintosh.
Feed Type of paper feed
1 or omitted Continuous (paper cassette)
2 Cut sheet or manual (manual feed)
Quality Specifies the DPI output quality you want. If omitted, the corresponding settings in the Page Setup dialog box will be used. If included, this argument overrides the quality argument in the PAGE SETUP dialog box.
Y_resolution corresponds to the Print Quality box in the Page Setup dialog box if you have specified a printer where the horizontal and vertical resolution are not equal, such as a dot-matrix printer. If omitted, the corresponding settings in the Page Setup dialog box will be used. If included, this argument overrides the print quality setting in the Page Setup dialog box.
Selection specifies what portion of the sheet to print.
Selection Portion printed
1 Prints the current selection from all selected sheets. For example, if A1:F40 is selected on the active sheet, A1:F40 will be printed from each of the selected sheets.
2 Prints the print area or entire sheet from all selected sheets.
3 Prints print area or entire sheet from all sheets in the workbook.
Related Functions
PAGE.SETUP Sets page printing specifications
PRINT.PREVIEW Previews pages and page breaks before printing
PRINTER.SETUP Identifies the printer
SET.PRINT.AREA Defines the print area
SET.PRINT.TITLES Defines text to print as titles
DEFINE.NAME Equivalent to choosing the Define command from the Name submenu on the Insert menu
List of Command-Equivalent Functions
Macro Sheets Only
Equivalent to choosing the Print command from the File menu. Prints the active workbook.
Arguments correspond to options, check boxes, and edit boxes in the Print dialog box. Arguments corresponding to check boxes are logical values. If an argument is TRUE, Microsoft Excel selects the check box; if FALSE, Microsoft Excel clears the check box.
Syntax
PRINT(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
PRINT?(range_num, from, to, copies, draft, preview, print_what, color, feed, quality, y_resolution, selection)
Range_num is a number specifying which pages to print.
Range_num Prints the following pages
1 All the pages
2 Prints a specified range. If range_num is 2, then from and to are required arguments.
From specifies the first page to print. This argument is ignored unless range_num equals 2.
To specifies the last page to print. This argument is ignored unless range_num equals 2.
Copies specifies the number of copies to print. If omitted, the default is 1.
Draft This argument overrides the draft argument from the PAGE.SETUP function. If omitted, the Draft Setting from the Page.Setup function is used.
Preview is a logical value corresponding to the Print Preview button in the Print dialog box. If TRUE, the print preview window will be displayed. If FALSE, the window will not be displayed
Print_what is a number from 1 to 3 that specifies what parts of the sheet or macro sheet to print. If a chart is active, print_what is ignored. This argument will override the setting in the Page Setup dialog box. If omitted, the note argument in the Page.Setup function is used to determine whether to print notes or not.
Print_what Prints
1 Sheet only
2 Notes only
3 Sheet and then notes
Color corresponds to the Print Using Color check box. Color is available only in Microsoft Excel for the Macintosh. If omitted, the setting is not changed.
Feed is a number specifying the type of paper feed. Feed is available only in Microsoft Excel for the Macintosh.
Feed Type of paper feed
1 or omitted Continuous (paper cassette)
2 Cut sheet or manual (manual feed)
Quality Specifies the DPI output quality you want. If omitted, the corresponding settings in the Page Setup dialog box will be used. If included, this argument overrides the quality argument in the PAGE SETUP dialog box.
Y_resolution corresponds to the Print Quality box in the Page Setup dialog box if you have specified a printer where the horizontal and vertical resolution are not equal, such as a dot-matrix printer. If omitted, the corresponding settings in the Page Setup dialog box will be used. If included, this argument overrides the print quality setting in the Page Setup dialog box.
Selection specifies what portion of the sheet to print.
Selection Portion printed
1 Prints the current selection from all selected sheets. For example, if A1:F40 is selected on the active sheet, A1:F40 will be printed from each of the selected sheets.
2 Prints the print area or entire sheet from all selected sheets.
3 Prints print area or entire sheet from all sheets in the workbook.
Related Functions
PAGE.SETUP Sets page printing specifications
PRINT.PREVIEW Previews pages and page breaks before printing
PRINTER.SETUP Identifies the printer
SET.PRINT.AREA Defines the print area
SET.PRINT.TITLES Defines text to print as titles
DEFINE.NAME Equivalent to choosing the Define command from the Name submenu on the Insert menu
List of Command-Equivalent Functions
Re: VBA и принтер
нямам пример засега ... от Macrofun.hlp е
Имаш го и ти, защото беше дал някъде линк към него.
Мислех си вчера, че и с WAIT(NOW()+"00:01:00") може да стане, обаче пак някой може изпредвари с друга заявка към принтера през това време и да развали бланките ...
Имаш го и ти, защото беше дал някъде линк към него.
Мислех си вчера, че и с WAIT(NOW()+"00:01:00") може да стане, обаче пак някой може изпредвари с друга заявка към принтера през това време и да развали бланките ...
Re: VBA и принтер
Fast Taker,
що не постнеш кода тук, за да мислим заедно как да стане с тва ПРИНТ?
що не постнеш кода тук, за да мислим заедно как да стане с тва ПРИНТ?
Re: VBA и принтер
Ами то кода не от съществено значение, но ето го:
Sub Print1()
CheckForPrinting
For ii = 1 To Sender Step 2
ThisWorkbook.Sheets("DC" & ii).PrintOut copies:=1
Next
End Sub
Sub Print2()
CheckForPrinting
For ii = Sender To 2 Step (-2)
ThisWorkbook.Sheets("DC" & ii).PrintOut copies:=1
Next
End Sub
Sub CheckForPrinting()
For Each xx In ThisWorkbook.Sheets
If Not (xx.Name Like "DC1" Or _
xx.Name Like "DC2") Then
If IsEmpty(xx.Range("I3")) Then
Sender = xx.Name
Exit For
End If
End If
Next
Има два бутона: един за четните страници, другия за нечетни. Целта e двата макроса да се слеят в един и между тях нещо да накара принтера да преминe на manual feed :-/
Sub Print1()
CheckForPrinting
For ii = 1 To Sender Step 2
ThisWorkbook.Sheets("DC" & ii).PrintOut copies:=1
Next
End Sub
Sub Print2()
CheckForPrinting
For ii = Sender To 2 Step (-2)
ThisWorkbook.Sheets("DC" & ii).PrintOut copies:=1
Next
End Sub
Sub CheckForPrinting()
For Each xx In ThisWorkbook.Sheets
If Not (xx.Name Like "DC1" Or _
xx.Name Like "DC2") Then
If IsEmpty(xx.Range("I3")) Then
Sender = xx.Name
Exit For
End If
End If
Next
Има два бутона: един за четните страници, другия за нечетни. Целта e двата макроса да се слеят в един и между тях нещо да накара принтера да преминe на manual feed :-/
Редактирано от Fast Taker на
Re: VBA и принтер
sorry ... Feed is available only in Microsoft Excel for the Macintosh... сега го видях (пише го на ред 25)
Оказа се, че аз нямам такова копче за manual на принтера, с който съм в офиса. Автоматично си е по подразбиране, затова не можах да го тествам по описания от теб начин...
Но виж какво измислих.
Ако си добавиш още веднъж същия принтер, но с друга настройка (manual) и само за първото четно превключиш на него, а после се върнеш на основния принтер ще стане.
При мен са два мрежови на \\Work11\hp
1. hp LaserJet 1000 – (ако този е default)
2. hp LaserJet 10001 (тук съм настроила да излиза по средата на листа CONFIDENTIAL ) ти си правиш настройка manual за него
и:
Sub Print1()
CheckForPrinting
For ii = 1 To Sender Step 2
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
Next
Call Print2
End Sub
Sub Print2()
CheckForPrinting
flag = 0
For ii = Sender To 2 Step (-2)
If flag = 0 Then
Application.ActivePrinter = "hp LaserJet 10001 on \\Work11\hp"
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
flag = 1
Else
Application.ActivePrinter = "hp LaserJet 1000 on \\Work11\hp"
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
End If
Next
End Sub
---------------------------------------------------------------
Или при мен при следния код първо печата Sheet1 с default принтера, после отива на Sheet2 и печата страница с едно CONFIDENTIAL по средата.
Sub Print3()
Sheets("Sheet1").Activate
Application.ActivePrinter = "hp LaserJet 1000 on \\Work11\hp"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Sheet2").Activate
Application.ActivePrinter = "hp LaserJet 10001 on \\Work11\hp"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Sub
Оказа се, че аз нямам такова копче за manual на принтера, с който съм в офиса. Автоматично си е по подразбиране, затова не можах да го тествам по описания от теб начин...
Но виж какво измислих.
Ако си добавиш още веднъж същия принтер, но с друга настройка (manual) и само за първото четно превключиш на него, а после се върнеш на основния принтер ще стане.
При мен са два мрежови на \\Work11\hp
1. hp LaserJet 1000 – (ако този е default)
2. hp LaserJet 10001 (тук съм настроила да излиза по средата на листа CONFIDENTIAL ) ти си правиш настройка manual за него
и:
Sub Print1()
CheckForPrinting
For ii = 1 To Sender Step 2
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
Next
Call Print2
End Sub
Sub Print2()
CheckForPrinting
flag = 0
For ii = Sender To 2 Step (-2)
If flag = 0 Then
Application.ActivePrinter = "hp LaserJet 10001 on \\Work11\hp"
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
flag = 1
Else
Application.ActivePrinter = "hp LaserJet 1000 on \\Work11\hp"
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
End If
Next
End Sub
---------------------------------------------------------------
Или при мен при следния код първо печата Sheet1 с default принтера, после отива на Sheet2 и печата страница с едно CONFIDENTIAL по средата.
Sub Print3()
Sheets("Sheet1").Activate
Application.ActivePrinter = "hp LaserJet 1000 on \\Work11\hp"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Sheet2").Activate
Application.ActivePrinter = "hp LaserJet 10001 on \\Work11\hp"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Sub
Re: VBA и принтер
Това може би е някакво решение, макар малко мечешко :))). За съжаление не можах да го тествам, защото Windows не ми дава да си сложа същия принтер два пъти. А и ще трябва да го направя и на другите компютри, от които се печата със същия макрос.
Re: VBA и принтер
Мечешко - заешко ... като няма опция за feed тряа да го излъжем някси
Е, сигурно някои може да измисли нещо по-нормално, но си мълчат
Принтера под друго име трябва да го инстарилаш, но със същият драйвер. Всъщност не съм пробвала как става това с local принтер... с network стана.
Е, сигурно някои може да измисли нещо по-нормално, но си мълчат
Принтера под друго име трябва да го инстарилаш, но със същият драйвер. Всъщност не съм пробвала как става това с local принтер... с network стана.
Re: VBA и принтер
А уе, френд,
Аз не съм много добър с VBA ама ми се струва, че и без него ще минеш.
Начи принципно като дадеш принт, ама не с иконката, а с Ctrl+P, нали ти излиза едно меню. На него горе в дясно има Properties. Цъкаш там и после на Finishing. Там в Document options слагаш отметка на Print On Both Sides. По тоя начин ще ти отпечата първа страница, на гърба й - втора, след това трета, а на гърба й четвърта и така до края на света. При това никой не може да ти се намърда между лицата и гърбовете, щото ти всъщност печаташ наведнъж въпросния файл.
Мисля, че ако си разположиш страниците по подходящ начин, това ще ти свърши работа. И ако съм прав - шъ черпиш една боза
Аз не съм много добър с VBA ама ми се струва, че и без него ще минеш.
Начи принципно като дадеш принт, ама не с иконката, а с Ctrl+P, нали ти излиза едно меню. На него горе в дясно има Properties. Цъкаш там и после на Finishing. Там в Document options слагаш отметка на Print On Both Sides. По тоя начин ще ти отпечата първа страница, на гърба й - втора, след това трета, а на гърба й четвърта и така до края на света. При това никой не може да ти се намърда между лицата и гърбовете, щото ти всъщност печаташ наведнъж въпросния файл.
Мисля, че ако си разположиш страниците по подходящ начин, това ще ти свърши работа. И ако съм прав - шъ черпиш една боза
Редактирано от f(x)dx на
Re: VBA и принтер
Е, айде сега да не се сърдим :)))
Това с принтера не става, защото никъде не ме пита за име, нито мога да му го сменям, а и съм power user и съм с поограничени права
:))
Това с принтера не става, защото никъде не ме пита за име, нито мога да му го сменям, а и съм power user и съм с поограничени права
Re: VBA и принтер
За бозата нямаш проблеми, цяла вечер ше се лее ... може и шоколадови бисквити да намерим 
...
Това за което говориш май го няма като екстра на моя притер, иначе беше идеалният вариант - дуплексен принтер, дори нямаше да ставам да обръщам страниците
Това за което говориш май го няма като екстра на моя притер, иначе беше идеалният вариант - дуплексен принтер, дори нямаше да ставам да обръщам страниците
Редактирано от Fast Taker на
Re: VBA и принтер
Не може да го няма, пробвай. Досега все така съм се оправял и действа.
Re: VBA и принтер
Не всички принтери притежават тази възможност да печатат двустранно.
Човек съм и нищо човешко не ми е чуждо
Човек съм и нищо човешко не ми е чуждо
Re: VBA и принтер
Прав си, намерих го, но не става - отделните страници за печатане са на отделни sheets и на практика това са отделни файлове за печатане. Дори по някакъв начин да се съберът на един sheet ще трябват 3-4 натискания с мишката, в момента макроса го прави с две. Целта все пак е улесняване на процедурата, като се сведе до едно кликване и това да остане незабелязано за крайния потребител, за да бъдат всички доволни
Мерси за хелпа
Мерси за хелпа
Re: VBA и принтер
Тогава можеш да се пробваш да събереш отделните шийтове на един, който да разпечатваш. Това обаче може да вдигне много обема.
Другият вариант е да промениш макроса така, че да печата наведнъж, шийтовете, но в реда, който те устройва.
Просто давам идеи, не че разбирам много от VBA
Другият вариант е да промениш макроса така, че да печата наведнъж, шийтовете, но в реда, който те устройва.
Просто давам идеи, не че разбирам много от VBA
Re: VBA и принтер
а така? :)
Чака те една минута преди да започне да принти четните да отидеш да си обърнеш листата и продължава.
Sub Print1()
CheckForPrinting
For ii = 1 To Sender Step 2
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
Next
Call Print2
End Sub
Sub Print2()
CheckForPrinting
flag = 0
For ii = Sender To 2 Step (-2)
If flag = 0 Then
Application.Wait Now() + 1 / 24 / 60
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
flag = 1
Else
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
End If
Next
End Sub
Чака те една минута преди да започне да принти четните да отидеш да си обърнеш листата и продължава.
Sub Print1()
CheckForPrinting
For ii = 1 To Sender Step 2
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
Next
Call Print2
End Sub
Sub Print2()
CheckForPrinting
flag = 0
For ii = Sender To 2 Step (-2)
If flag = 0 Then
Application.Wait Now() + 1 / 24 / 60
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
flag = 1
Else
ThisWorkbook.Sheets("DC" & ii).PrintOut Copies:=1
End If
Next
End Sub