Changing printer to adobe

Hi!

I want to change printer to adobe, print document in pdf and replace the old printer. My problem is Notes change from printer to adobe only when i close notes. I want to do all in a bottom. This is my script:

Declare Function GetProfileString Lib “kernel32.dll” Alias “GetProfileStringA” ( _

Byval lpAppName As String, _

Byval lpKeyName As String, _

Byval lpDefault As String, _

Byval lpReturnedString As String, _

Byval nSize As Long ) As Long

Declare Function WriteProfileString Lib “kernel32.dll” Alias “WriteProfileStringA” ( _

Byval lpszSection As String, _

Byval lpszKeyName As String, _

Byval lpszString As String ) As Long

Declare Function SendMessage Lib “user32.dll” Alias “SendMessageA” ( _

Byval hwnd As Long, _

Byval wMsg As Long, _

Byval wParam As Long, _

lparam As Long ) As Long

Declare Sub SleepWin Lib “Kernel32.dll” Alias “Sleep” (Byval Milliseconds As Long)

Sub Click(Source As Button)

Const ok_info = 64

Const ok_excl = 48

Const yesno_excl = 52

Const ok_stop = 16

'Set default printer to be Adobe Writer

Dim szPrinter As String

szPrinter = "Adobe PDF"

'szPrinter = "\\CCD_MTL\Orlando.IMPRIMANTES.info"



'On Error Goto ErrorHandler



Const HWND_BROADCAST = &HFFFF

Const WM_WININICHANGE = &H1A

Const WM_SETTINGCHANGE = &H1A



Dim rc As Long

Dim slength As Long

Dim SendCommand As String

Dim oldprinter As String

Dim t As Long

Dim buffer As Variant

buffer = Space(1024)

Dim buflen As Long

buflen = Len(buffer)



rc = GetProfileString( "Devices", szPrinter, "", buffer, buflen )

Dim drivername As String

Dim printerport As String

t = Instr(buffer, ",")

If t > 0 Then 

	drivername = Left(buffer, t - 1 )

	k = Instr(t + 1, buffer, "," )

	If k > 0 Then

		printerport = Mid( buffer, t + 1, k - t - 1 )

	End If

Else

	Messagebox "You do not have the correct printer driver installed for this function. If the Adobe Acrobat PDFWriter Printer driver has been installed, please rename it to Acrobat PDFWriter."

	Exit Sub

End If

buffer = String(128, 0)

slength = GetProfileString("Windows", "Device", "(error)", buffer, 128)

OldPrinter = Left(buffer, slength) ' extract the returned string from the buffer

If OldPrinter = "(error)" Then

	Print "Could not read information from WIN.INI."

Else 

	Print "Original Printer: " & OldPrinter

End If

buffer = Space(1024)

buflen = Len(buffer)



rc = GetProfileString( "PrinterPorts", szPrinter, "", buffer, buflen )



i = Instr(buffer, ",")

If i > 0 Then 

	drivername = Left(buffer, i - 1 )

	k = Instr( i + 1, buffer, "," )

	If k > 0 Then

		printerport = Mid( buffer, i + 1, k - i - 1 )

	End If 

End If

Dim newprinter As String

newprinter = szPrinter & "," & drivername & "," & printerport

rc = WriteProfileString( "windows", "Device", NewPrinter)

rc = SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE,0,0)

Call SleepWin(3000)

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’

Dim ws As New notesuiworkspace

Dim uiview As NotesUIView

pageseparator = 1

Set uiview = ws.Currentview

'Call uiview.Print( 1,,,,, "Demande+historique",,, )

'Call uiview.Print

'change default printer back

rc = WriteProfileString( "windows", "Device", OldPrinter)

rc = SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE,0,0)

Call SleepWin(3000)

buffer = String(128, 0)

slength = GetProfileString("Windows", "Device", "(error)", buffer, 128)

NewPrinter = Left(buffer, slength) ' extract the returned string from the buffer

If NewPrinter = "(error)" Then

	Print "Could not read information from WIN.INI."

Else

	If NewPrinter = OldPrinter Then

		Print "Original Printer: " & OldPrinter

	Else

		While NewPrinter <> OldPrinter

			rc = WriteProfileString( "windows", "Device", OldPrinter)

			rc = SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE,0,0)

			Call SleepWin(3000)

			buffer = String(128, 0)

			slength = GetProfileString("Windows", "Device", "(error)", buffer, 128)

			NewPrinter = Left(buffer, slength) ' extract the returned string from the buffer

		Wend

	End If

End If

End Sub

Estelle

Subject: changing printer to adobe

First, please don’t double post - it clutters up the forum and doesn’t get you an answer any faster.

Second - try a quick search of the forum; this is one of those topics that shows up a lot.

http://www-10.lotus.com/ldd/nd6forum.nsf/Search?SearchView&Query=change%20and%20printer&SearchOrder=0&Start=1&Count=100

Quick hint - controlling printers is not very easy in Notes; the printer belongs to the OS.

Third - you probably don’t know about the FAQs since they’re not displayed in this forum, but if you visit the 4/5 forum, there is a link to FAQ’s including one called the FAQ of FAQ’s

http://www-10.lotus.com/ldd/46dom.nsf/7e6c7e584a76331b85256a46006f083e/1c653d514d1db0ae852569620057ef1f?OpenDocument

Look for ‘printer’ and you’ll find a number of interesting posts.

HTH

Doug