Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Select Printer From A Macro??


I have a form with an OK button that will print the activesheet, but, I want the user to be able to select a printer other than the default printer. Can I do this? I'm pretty new with VBA. I'm using Excel97 with Windows 98. Send me e-mail if you absolutely know the answer. Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Select Printer Tray - Common Dialogue Show Printer
I'm using the following code to show the common dia... control. The user selects the printer and number of copies... Then access is opened in the background and queries a report and prints it. It prints to the correct printer, and the correct number of copies...

BUT...

We recently switched one of our network printers out and for some reason now, the printer ONLY prints from this program to the 3rd tray, which contains invoice paper. I use the common dialoge to change the tray and that doesn't do it. I even go into the printer options and specify the correct tray and it still comes out on the wrong one...

How can I fix this?


Code:
Private Function PrintOrder()
Dim StrCopies As Integer
Dim IntCopies As Integer
CD1.ShowPrinter
IntCopies = CD1.Copies
Dim acApp As Access.Application
Dim strSQl As String
strSQl = "[ID]=" & Me.txtrecid.Text
Set acApp = New Access.Application
acApp.OpenCurrentDatabase "\SERVERAction FilesLightingVB6OrderOrders.mdb"
acApp.DoCmd.OpenReport "Order", acViewPreview, , strSQl
acApp.DoCmd.PrintOut acPrintAll, , , acMedium, IntCopies
acApp.Quit
Set acApp = Nothing
End Function

Macro For Printer Specification??
hi guys,

I know how to create a macro to alter the page set-up settings etc. but what I want to do is actually create a macro that will go outside of word and allow me to change the printer settings.

There is a big document which I want printed double sided. I cannot default the document to print double sided because it is printer setup, not page setup.

We have big mutha printers and I want to be able to create a macro which will actually print the document double sided - part of the printer specifications.

Any ideas? I can post the actual printer settings if anyone can point me in the right direction.

cheers

Macro To Select Current Record
You can select the current record in an Access 2000 DB by holding down the "Shift"+"Spacebar"

I wanted to use this in a macro to select and then copy the whole record. However I can not find the "keycode" for "Spacebar"

I have look on Microsofts site and tried the following

     +" "

     +{space}

     +{spaceba}

Any support would be greatly appreciated

thank you


Pre-select Printer And Printer Bin
Is it possible to pre-select a printer and printer bin to print a report to?
I've written a program that prints out labels on envelopes, and I want it to only print to a certain printer and its' envelope bin.

Select A Printer
Is there a way to select a specific printer? I have two printers installed and insted of the printer selection box comming up can i specify what printer i want and it just print to it? Example if i have printer1 and printer2 i don't want to show the dialog box, I just want it to select the printer2. BUT printer1 is my default printer.

Cannot Select Printer
Hey,

I have a form with a crystal viewer on it.
When the user clicks on the print button of the viewer, he cannot select the printer he wants to print to.
I think the default printer is showing up, but not sure.
Am i missing some setting?
How can this be fixed?

Thanks

Select A Printer
I am having a problem selecting a printer to which i want my program to print.


Code:
Private Sub FillcmbPrinters()
Dim devPrinter As Printer

For Each devPrinter In Printers
cmbPrinters.AddItem devPrinter.DeviceName
Next
cmbPrinters.Text = Printer.DeviceName
End Sub

That piece fills the combobox cmbPrinters with a list of the printers, and selects the windows default printer. The combobox is a style 2 (dropdown list) one. So far so good.


Code:
Set Printer = Printers(cmbPrinters.ListIndex)

That line is executed whenever the selected line of the cmbPrinters combobox is changed. If I echo Printer.DeviceName to a textbox, it shows that Printer.DeviceName indeed contains the printer which is selected in the combobox. However, if right after that I have a printer.print command, it will print to the windows default printer no matter what.

I'm using vb5.0 on win2000. Just for debugging, im using a generic text printer (prints to file) next to my normally default printer. The program will need to run on win98, 2000 and XP.

Select Printer 's Name.
Hi there,
I want to print some lines using the Printer object in my VB. But I can not sepecify the printer's name which I want to print out. My code is something like this:

Printer.DeviceName = strPrinterName 'Error from this line of code

Printer.Orientation = 1
Printer.PaperSize = 9
Printer.Print "My string"

The error is that : "Wrong number of arguments or invalid property assignment."
Pls show me how to sepecify a printer through its name when using Printer Object?
Thanks in advanced.

How To Select Printer
hi everyone,
I am using code to print report

printer.printreport
worked well.but my Problem is this in my computer more then one printer installed I want to do when I command for print system did not ask for me about printer I want to set it through code.If any one know kindly tell me

Select Printer
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Dim PrintIt As Long
PrintIt = ShellExecute(Me.hwnd, "PRINT", "C:logon.doc", "", "", -1)
End Sub




Does someone know how select a printer and print a word document?

thx
charly

Select Printer
How to select a printer with no commondialog ?

Select A Printer
I have two identical printers installed in the same PC/Win98. I use this code to select the printer.


Code:
Dim prnObj as Printer
For each prnObj In Printers
if prnObj.DeviceName = "X Printer" then
Set Printer=prnObj
end if
next


This printer is attahced in a LPT2: port.
I use several printer methods but the priting job always go to printer in LPT1: (default printer).

Any idea will be deeply appreciated.

Thanks!

Select Printer
Hi

I belive it to b a simple question

How do u specify the printer an excel doscument should be sent to in your print command

 xlsCallSheet.ActiveSheet.PrintOut
 xlsCallSheet.ActiveWorkbook.Close False
 xlsCallSheet.Quit
 Set xlsCallSheet = Nothing

I'm using the above code, does it get added on to the "printout" command

I tried this with the common dialogue box however although it allowed me to select the printer the xl sheet didnt print.

Any help would be appreciated

Thanx

Nik

knowledge is nothing
knowing is everything
living it is eternal

Edited by - niko on 8/10/2004 5:02:57 PM

Cannot Select Printer
Hey,

I have a form with a crystal viewer on it.
When the user clicks on the print button of the viewer, he cannot select the printer he wants to print to.
I think the default printer is showing up, but not sure.
Am i missing some setting?
How can this be fixed?

Thanks

How To Select A Radio Button With An Excel Macro?
I have a worksheet that does a calculation and a macro to reset the worksheet after each calculation. One of the options on the worksheet is a radio button where you select either Residential or Business. I'd like the macro that resets the worksheet to select Residential when it is run, but I have not been able to find out how to do this.

I have found that I can use Application.Run to run the macro associated with the button, but this doesn't make the button appear to be selected.

Can somebody please tell me how to select this radio button within a macro?

Thank you for your time.

VB Macro For Printing Select Worksheets In Excel
Hi there

I've got an Excel Workbook with multiple Sheets. I have a macro for printing most of the Worksheets but most of the time only a third of them hold any data and I just end up wasting a lot of paper and ink.
Does anyone have a script, or extract of, that will only print a sheet if data has been entered in one or more cells on that sheet?
Before I just printed off the sheets I needed manually but most of my colleagues ouldn't quite get the hang of that.

Any help greatly appreciated

Dan

Excel Macro - How To Select Used Cells In A Column?
Hello!
solutin is in the last post

I'm trying to workaround this problem: http://support.microsoft.com/defaul...kb;en-us;815277

this changes data in a selection to make it REALLY of text type, provided the cells were already text type.

If anyone knows another way to achieve the same result, that is welcome too. (convert mixed numeric and text data in the same column to only text data).

This is NOT achieved by going to Format -> Cells -> text

Although this is a required previous step for the method in the link above. The numbers are only stored as text once a space is entered before the number in the cell. We can delete the space later and the number will remain stored as text.

So,
I need a macro to do the following: select used cells in a specific column.
I need to select column "values" but not the entire column, only the used rows (it is possible that there are empty cells in this column, that should not matter, I need to select the cells if there is a corresponding non-empty cell in column "dt")

for example:

Code:


column a | column b | dt | column x | values | column z
....a....|....b.....|.1..|....x.....|...123..|....z....
....a....|....b.....|.2..|....x.....|........|....z....
....a....|....b.....|.3..|....x.....|...456..|....z....
....a....|....b.....|.4..|....x.....|........|....z....


here i would need to select 5 cells from column values, counting title cell






I already know that changing data type is achieved with:

Code:
Selection.NumberFormat = "@"


all I need now is select the cells I want to change...

Hope anyone can help me
Cheers

Select Printer And Paperbin In Vb
Hi all.

I've got a problem with selecting a networkprinter and a certain paperbin in VB6.

This is what I do:


Code:
Set Printer = "\10.10.1.101Kyocera Mita KM-2030 KX"

Printer.PaperBin = 3 'Case 2 from that networkprinter.
When running this code VB give me the following error in the first line of the code above: Object required.

So when delete the first line and use the standard printer (which, in this case, is the printer I want to use) he doesn't use Case 2 but Case 1. And I know that PaperBin 3 is Case 2 because I used the DeviceCapabilities API to check that.

Select Printer In POwerpoint??
I would like to let the user to select which printer the current slides will print to. How do I do this?

Can anybody help me out??

Select Page In Printer Using VB6
Hi,

I have a data sheet in VB6 and need to print off the reports which must be duplex. Each duplex sheet contains 6 different records. Each record needs to print to the front and rear of the same sheet.
Using the printer method. How do you select what side/page you which to send the data to so it can be printed?

Thanks

P.S. The Printer.Page is read only.

User Select Printer
I need to know how to set the printer to what the user selects in the common dialog box. Any help would be greatly appreciated.

VB In Word To Select Printer
I have written a script in Word to have a file print to the same label printer everytime.
I used the following
Option Explicit
Private Sub Document Open()
With Dialogs(wdDialogFilePrintSetup)
.Printer = "Label Printer Name"
.DoNotSetAsSysDefault = True
End With
End Sub

The label printer is conected to a PC and not to a printer server. I can get this script to work with any other printer but this one. One the server the printer name shows as sc_label on Desktop2. We are using remote desktop to access the server to run the word files.
Any Ideas?

Select Color Printer
Can I automatically find and set the default printer in VB Code?
I want to select a color printer, if one exists.

Thanks

How To Select Printer By Code?
I want my program to have a combo box that contain all of system printer's name and allow users to choose the printer for their job. How can I code my program? I don't know about printer's object, functions and API to complete it!! Could someone help me please?
Thank you.

VBA: How To Select A Printer On The Network.
Dear VB users,

Writing a VBA application, I do have to select a printer on the network.
Is this possible in VBA

In VB I am using:

Dim MyPrinter as Printer
For each MyPrinter in Printers
msgbox MyPrinter.DeviceName
next

Please can someone give me VBA source and/or information wich references I do have to choose.

Nice greetings,

Michelle.

Select Printer Programatically
Use the Printers Collection, eg.

Code:
Dim oPrn As Printer
'Send Print to Every Printer Driver in the Printers Folder..
For Each oPrn In Printers
Set Printer = oPrn
Printer.Print "Printing on.. " & Printer.DeviceName
Printer.EndDoc
Next



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

How Can I Select A Printer In Module?
Hi,

I understand that CommonDialog can handle printer object but how can I select a specific printer in module level before printing?

KC

[SOLVED] Cannot Select Printer
Hey,

I have a form with a crystal viewer on it.
When the user clicks on the print button of the viewer, he cannot select the printer he wants to print to.
I think the default printer is showing up, but not sure.
Am i missing some setting?
How can this be fixed?

Thanks



Edited by - Nasty on 2/14/2006 12:10:24 AM

Select Printer When Using PrintForm
I have using printForm function to print a form out using VB6.
However, the printer it select is always be the default printer.
How can I prompt the user to choose the available printer like the one in MS word without changing the default printer?




Edited by - ustreddog on 2/10/2004 11:00:01 PM

How Do I Select IE Option Element With No Name, Value, Or Title In An Excel Macro
Hi!

I'm trying to automate webform from an Excel macro using values from Excel. I am running into a problem with a particular part that uses a Select element and several option elements that I am unsure of how to access in the macro. I know I can use the .selectedIndex property to set the option on the page but I need to be able to "read" the text display of the options into a string to compare with a value on the spreadsheet. I do not have the ability to modify the html code. I have posted the html code and the current macro code. I would be ever grateful for any assistance you all could provide.
HTML:

<select size="1" name="equipmentDescription" style="position: relative; width: 357; height: 23">
<option> Item 1 </option>
<option> Item 2</option>
<option> Item 3</option>
<option> Item 4</option>
</select>

VBA:

App.document.all("equipmentDescription").selectedIndex = (A # between 0 - 115)

The vba code will change the selection to the item but I need to get the text of each item to determine the number correctly because the options list changes daily.

Thanks for all your help in advance.

Select File To Open Using Macro And Windows Browser?
Hi

What I need to do is write a bit into my macro that lets the user select the file they want to open (more accurately to name the path and filename of a workbook they wish to open) so that i can use the path and filename to open the XLS and then copy some of the data into my new workbook.

The files to import data from are not named with any convention, nor are they located on a fixed location (is a server which can change drive mapping letter depending on the user's computer!). What I wanted to do was have a window pop up (like the standard File, Open window) which allows the user to browse to their XLS and select it.

The macro would then set the path and filename into a variable so the XLS can be opened and referenced.

Is this possible?

Regards

Rob

How Do I Get A Macro To Select A Cell Depending On Another Cells Data
this problem may be a simple one but as im not very good in visual basic i cannot think of a function to use.
here is an example of my problem.

I have a cell number in one cell.
Cell G1 has the data D5 in it.
And i need a macro to select cell D5 by using the info it found in cell G1.

Sorry if that isnt very clear but i cant think of any other way of explaining it. please help.

In Excel, Select Whole Row, Run Macro, End By Selecting Original Row Automatically
I have an Excel spreadsheet macro which takes off the auto-filter and then after carrying out various functions, puts the auto-filter back on again. The functions in the macro need the whole of one row to be chosen manually before running the macro. I want to end the macro by automatically highlighting the whole of the row that was orignally chosen. I assume I would need to save the address of the original ActiveCell/Row, say as a variable, and after carrying out the various functions, return to the saved address, ie: the original ActiveCell/Row. Can you give some guidance please.

 

How To Select A Printer Without Setting The Default?
How do you going about selecting a printer, without setting the default printer?
If you use the Common Dialog control (vb6SP3) then it will set the default printer for the computer, which i don't want to do.
Any ideas on this one?
BW

How To Select A Printer In VB Crystal Report.
Hi

How to select a printer in vb.

I have VB5, VB6 & Crystal Report.

My crystal reporter PRINT button Active only WINDOWS DEFAULT PRINTER.

Every time we are go to Control Panel - Printer Settings - select a printer & set as Default Printer.

I want choose the printer name in RUN Time.

I tried to Common Dialog aslo.

Is it possible ?

How to write the coding / settings.

By
IRAM

Select Printer - Crystal Reports 8
Hi there!


I'm using VB6 + CR 8 RDC + CRViewer.

I need to make it available for the user to choose the printer he wants the report to be printed.

Thanks for all your attention!

How To Create Excel Multi-select List Box To Work In A Macro?
Hi
I need to create an excel multi-select list box on a worksheet, so that the user can make multiple selections. The examples that I found from the help index are meant for activeX list box (which is not what I want).
My questions are : (1) how to create an excel (multi-select) list box to work in an excel macro? (2) When the user to click on the right mouse button, the multiple selections will be transferred to another excel list box. How do I write code to do this? Thank you.

Select A Printer Programatically For Crystal Reports 10
I have an application in VB 6 which prints reports in Crystal Reports 10 without user prompting. I need to programatically change the printer depending on the report. I tried with "call CRreport.selectprinter (PrinterDrv, PrinterName,PrinterPort)" and with "set printer = MyChosenPrinter" but the program prints always in the system's printer.
Thank you for your help. I need it!

Crystal Reports RDC / Allow User To Select Printer
I need to know how to allow the user to select a printer when printing Crystal reports as opposed to just sending to the default printer.

I am currently designing my reports using RDC. I have a single form (frmRptView), with only the CRViewer control, which I call to view all of my reports.

Here is the code I am using to view a report:

Private Sub cmdViewReport_Click()

Dim Report As New NameOfReport

With frmRptView
.CRViewer1.ReportSource = Report
.Show
.CRViewer1.ViewReport
End With

End Sub

Now I am looking to find the code to utilize under the CRViewer1_PrintButtonClicked event procedure to allow the user to select printer. Under Crystal Care Technical Support I found the following code:

Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)

'Do not use the default printer dialog
UseDefault = False

'Display the Windows Standard Printer Setup dialog box.
Report.PrinterSetup Form1.hWnd

'Print the report without displaying the default printer dialog.
'If the option to set the number of pages is required then
'pass a value of True.
Report.PrintOut False

End Sub

Problems:

1> In my form (with the CRViewer1 control), it does not recognize Report as object.

2> If I hardcode in the name of the report it asks me to enter parameter values. I should mention this is a paramaterized report.

So first things first, If someone could tell me how I can refer to the report from the form which I view the report that would be a start.

Printer Only Prints 1 Page No Matter How Many I Select
Hi,

When i use the common Dialog for printing i have the option of how many pages to print, however when i select more than one, still only one page prints.

Can anyone help?

Thanks


Select And Copy Just Cell Content (not The Cell Itself) By VB Macro
Hi,
my problem is that I can select the content of Cell in Excel sheet [by doubleclicking (or F2) onto the Cell and simply select the whole text inside] and copy it as text.
But I cannot do this by macro.

Is there any chance to select content and copy it by VB macro?

How To Show &"Select Printer&" Dialog Before Printing A Crystal Report?
Hi everyone.
I use Crystal Reports 8.5
In my code I always call the: mycrviewer.ViewReport command. When the report shows up if I press print button it only shows me a dialog with the default printer to set number of copies and pages to print.
I would like to show up a dialog which let me select the printer and adjust other printer settings (like paper size, etc.) like DataReport does.
How can I do this?

Thanks for your time and help!

How To Show &"Select Printer&" Dialog Before Printing A Crystal Report?
Hi everyone.
I use Crystal Reports 8.5
In my code I always call the: mycrviewer.ViewReport command. When the report shows up if I press print button it only shows me a dialog with the default printer to set number of copies and pages to print.
I would like to show up a dialog which let me select the printer and adjust other printer settings (like paper size, etc.) like DataReport does.
How can I do this?

Thanks for your time and help!

Word Macro Insert File/ Append Table Macro Issue.
Hello,

I was wondering if someone could help me with this problem...

When I use the following code to insert a table (from an external file), the table that is inserted does not append to the table in first document (which is what I want it to do)...

Sub Macro1()

Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="m:cat.DOC", Link:=True

End Sub

Would anyone know how I can make the contents of this file append to the table in the first document?

Thanks so much in advance,

Anne

Macro Opens A Document In Vba, Saves, Then Continue With Macro
Maybe the title isn't correct, but i've got the following problem.
I build a document that open a form. On this form there is a checkbox. When the checkbox is active and I press 'OK' a document has to be opened. On this document some changes can be made, then by pressing 'continue' this document is saved on 'c: emp' and closed. Then I want to go back to the first document and continue with it.
Is there some sort of halt or wait funtion to establish this?

The code I use is the following:

<code document1>
If chbFinPar = True Then
Documents.Open FileName:="f:Nieuwe format macroHuisstijlTestversiefinpar.doc"
Selection.EndKey , ActiveDocument.Bookmarks("bmkfinpar").Range
Selection.InsertFile FileName:="c: empfinpar.doc"
End If
<end code>

<code document2>
Private Sub cmdVrdr_Click()
ActiveDocument.SaveAs ("c: empfinpar.doc")
ActiveDocument.Close
End Sub
<end code>

Word Macro Editor Opens When I Misspell A Macro Name
I'm using Word 2000, and pressing Alt+F8 to access macros - just text strings - and here's the trouble:

I'm trying to make it possible for everyone here to use Word macros from the server. I've put a file out there called Macros.dot and it works great. Every machine in the building can see it and use it. Trouble is, if a user misspells a macro name the macro editor opens by default. It doesn't realize the user has misspelled something and thinks the user wants to write a new macro under the "new" name. User can click the X to close the editor, of course, but has now created a blank macro with a name very similar to a real macro. This will drive people (especially the less tech savvy) nuts, and clog up the file Macros.dot with garbage.

Is there a way to disable the macro editor from opening if an incorrect (nonexistent) macro name is typed? A check box somewhere, perhaps? I've tried but can't seem to find it, if it's there.

Thanks

Openning Excel And Running Macro From Word - Macro
Ok - I have a DB which I export to Excel, I then run a macro to "Groom The Data". I then run word and run a Macro (MailMerge to print labels) which retrieves data from the excel spreadsheet groomed above. Everything is working fine, despite my novice knowledge of VB, but I would like to do this in a single click.

I use a command line shortcut to Launch word and automatically have it run the macro, but I still have to Launch Excel and manually run its macro first.

I did not find a command line switch to make excel launch and run a macro. Is there any way I can Lauch Word have its Macro link to excel, then launch and run the excel macros before performing the macro I have set up in word (mailmerge)

In Other Words I have working macros in Word and Excel, I want the Word Macro to force the Excel macro to run before completing the rest of its duties.

Thanks
WW

How To Hide Macro Option From Tools Macro, Macros
Hi,
Well, this is the situation. I created some macros (6) for a workbook. One this macros is adding a new Menu in the main Excel Menu. The idea is that the user does not need to go to options: Tools, Macros, Macro...and run the macro because I want them to do it from the menu specially created.
Also I prevented any user to edit the macros putting password if they want to see the codes.
Now How I can prevent a user to run all my macros from the option:
Tools, Macros, Macro...Can I hide a Macro from that menu?

Any way to remove this option in just this workbook not affecting the user if they want to work with a new one...?
Or may be a message saying that macro can be run from the menu if the user is trying too.
Any suggestion?
Thanks!
Gonza

Can You Get An Access Macro To Include Running An XL Macro
Is it possible to have an MS access run its own "thing" and in the middle of it all call on excel to run it owns macro?

Copyright 2005-08 www.BigResource.com, All rights reserved