Link to home
Start Free TrialLog in
Avatar of kurtrossr
kurtrossr

asked on

VB/NET changing default printer during application

I have written a web form that needs to change the default printer during the run based on a file that the machine uses,
so when a user fills out the form and hit the print button, the app checks the file for the machine name and then checks the file for the appropriate printers,
it then needs to change the default printer to the printer name on the file.using the printfile application which is set to use the default printer.
unless anyone is familiar with printfile to change the printername in that.
I tried the setdefaultprinter() Method but it isn't chnaging the default printer.
i
Thanks in advance
Avatar of kurtrossr
kurtrossr

ASKER

Thanks
Avatar of Éric Moreau
do you want to change the default printer of the server where the web app runs or the on the client ?
the default printer is already installed on the client, but it is a network printer
so for example the current printer is HP 3500
but clicking the print button the app has already determined the new printer, but before it prints it
needs to chnage the defualt to that printer which would be something like
\\{servername}\{printername
this is what i currently have
    <DllImport("Winspool.drv")> _
Private Shared Function SetDefaultPrinter(ByVal printerName As String) As Boolean

    End Function


and  then in on click event
 SetDefaultPrinter(printername)


Thanks in advance
you want to change the client default printer?

if your SetDefaultPrinter is in your .aspx.vb file, the code will run on the server and won't affect the client.
if you want the client, I doubt you can do it directly but check http://www.meadroid.com/scriptx/index.asp
It is a windows form which will actually run on the machine that it will need to change the defauklt.
so in essence I guess that will be fine,
any way to do it.
I thought I had it working but it seemed funny.

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial