Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Prompt user to select a printer using a checkbox within a user

I didn't receive anything recently to the best of my knowledge

Anyway, you must have one workbook open, the workbook that holds the code.

but before you assign the printer either open a new workbook and close it
(application.ScreenUpdating = False, open the workbook, set the printer,
Application.Screenupdating = True) or have you code check the number of
visible workbooks and if it is 0, then don't assign the printer. Do it when
there is a workbook. I don't know what you are doing, so I don't know what
is an acceptable/workable workaround, but that is what comes to mind.

--
Regards,
Tom Ogilvy

"Freddy" wrote in message
...
Tom, I previously sent you sample code regarding this subject. However, I
have since then resolved the issue by using an OptionButton instead of a
CheckBox. There is another related error. I invoke my code after starting
Excel. Hoever, I noticed that I must have at least one workbook active,
even
if it's just "Book1" for my code to work. I normally start Excel without
any
workbook open by using the "/e" option within my shortcut. I got around
the
problem by just removing the "/e" option. By default, Excel opens a
workbook
named "Book#". The error I get when there is no workbook open and run my
code
is: 'Run-time error 1004': Method 'ActivePrinter' of object '_Application'
failed. My preference is not to have any workbook open. Any ideas?

"Tom Ogilvy" wrote:

in the vbe, do View=Immediate window

or Ctrl+G

--
Regards,
Tom Ogilvy


"Freddy" wrote:

I do not know what you mean by "the immediate window". Please explain.

"Tom Ogilvy" wrote:

In the click event of the checkbox, you would set the assignment
string to
the application.Activeprinter

for example, if I query this value on my machine in the immediate
window:

? application.ActivePrinter
\\ARDAPS01\1D373C on Ne03:

so if this weren't the activeprinter, you could set it with

application.ActivePrinter = "\\ARDAPS01\1D373C on Ne03:"


here is some sample code recently posted by a respected contributor
that
will enumerate the printers:

Author: Michael Pierron

Private Sub ListPrinters()
Dim wshNetwork As Object
Dim oDrives As Object
Dim oPrinters As Object
Dim iCount As Integer
Dim sCurrentprinter As String
sCurrentprinter = Application.ActivePrinter
Set wshNetwork = CreateObject("WScript.Network"*)
Set oDrives = wshNetwork.EnumNetworkDrives
Set oPrinters = wshNetwork.EnumPrinterConnecti*ons
For iCount = 0 To oPrinters.Count - 1 Step 2
Debug.Print "Printer Port " & oPrinters.Item(iCount) _
& " = " & oPrinters.Item(iCount + 1)

Next
End Sub

The output goes to the immediate window.

--
Regards,
Tom Ogilvy


"Freddy" wrote:

How can I set things up within a userform so that a user can select
a network
printer using a checkbox prior to running other subroutines? I
already have a
userform that the user makes other selections using checkboxes. Any
suggestions?
I am aware of how to use Application.Dialogs(xlDialogPrint).Show,
however, I
do not want the user prompted. Rather, I want the user just to
select from at
least 2 available network printers.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I prompt the user to select a cell? [email protected] Excel Programming 1 December 19th 06 11:42 PM
User select printer in print macro sarah_tennessee Excel Programming 0 April 7th 06 07:56 PM
User select printer in print macro rocket0612[_11_] Excel Programming 5 April 7th 06 07:49 AM
create a pause in print macro to allow user to select printer Scott53 Excel Programming 1 September 7th 05 04:29 PM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:22 PM


All times are GMT +1. The time now is 10:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"