Napisałem program, który dodaje użytkownika w bazie i sieci, po czym drukuje dokument. Niestety problem polega na tym że drukowanie przechodzi tylko ma komputerach z Wordem 2010, a na starszych wersjach się wysypuje. Czy to problem referencji? 2003 mógłbym sobie darowac ale co zrobic ze działał chociaż dodatkowo z Wordem 2007.
Mam załączone następujące bibloteki:
Imports System.ComponentModel
Imports Microsoft.Office.Interop.Word
Imports Microsoft.Office.Interop
fragment z funkcja odpowiadająca za drukowanie:
Public Function PrintDoc(ByVal Username As String, ByVal Password As String, ByVal PrinterName As String, ByVal Plik As String) As String
Try
Dim poApp As Word.Application
Dim poDoc As Word.Document
poApp = New Word.Application
poApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone
poDoc = poApp.Documents.Open(Plik)
poApp.ActivePrinter = PrinterName
With poDoc
.Range.InsertParagraphAfter()
.Range.InsertAfter("Dane wymagane do uzyskania dostępu do Internetu:")
.Paragraphs.Item(1).Range.Font.Bold = True
.Paragraphs.Item(1).Range.Font.Size = 12
.Range.InsertParagraphAfter()
.Paragraphs.Item(2).Range.Font.Bold = True
.Paragraphs.Item(2).Range.Font.Size = 12
.Range.InsertAfter("Nazwa użytkownika: " & Username)
.Range.InsertParagraphAfter()
.Range.InsertAfter("Hasło: " & Password)
Try
'Print the Word document.
'.PrintOut(True, Fals, , , , , , , , , True)
Catch exc As Exception
Return ("Blad: " & exc.Message)
End Try
End With
'print it out
poDoc.PrintOut()
' poDoc.Close(Word.WdSaveOptions.wdPromptToSaveChanges)
'clean up
poApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
poApp.Quit()
poApp = Nothing
Catch ex As Exception
Return Err.Description
End Try
Return "OK"
End Function