Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I prompt the user to select a cell? | Excel Programming | |||
User select printer in print macro | Excel Programming | |||
User select printer in print macro | Excel Programming | |||
create a pause in print macro to allow user to select printer | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming |