>Hello.
>I write code for Set default windows printer
>I have strange problem. When I place MSGBOX("Run") in method.. I see.. Default printer was set. But If I rem MSGBOX() the old printer stay as default.
>Can you explain that?
>Thank you
>
>Here code:
>
> Dim x As Printer
> i = 0
> For Each x In Printers
> If x.DeviceName = "Office eBiz Fax" Then
>
>
MsgBox ("Set Office eBiz Fax as Active printer") > szPrinter = Printers(i).DeviceName & "," & Printers(i).DriverName & "," & Printers(i).Port
> l = WriteProfileString("Windows", "Device", szPrinter)
> l = SendNotifyMessage(HWND_BROADCAST, WM_WININICHANGE, 0, "Device")
> l = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, "windows")
>
> End If
> i = i + 1
> Next
Place a
DoEvents instead of your msgbox.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com