واذا اردت استخراج اسماء الطابعات برمجيا
هذه الوحدة النمطية للحصول على اسماء الطابعات المثبتة في جهازك
Public Function GetPrinters() As String
Dim prn As Printer
Dim strPrinter As String
If Application.Printers.Count > 0 Then
For Each prn In Application.Printers
strPrinter = strPrinter & """" & prn.DeviceName & """;"
Next
GetPrinters = Left$(strPrinter, Len(strPrinter) - 1)
End If
End Function
ويمكنك مناداة الوحدة النمطية اعلاه واظهار الاسماء في مربع تحرير داخل النموذج
اكتب هذا الكود في حدث الفتح او التحميل للنموذج
Dim strMsg As String
Dim strTemp As String
strTemp = GetPrinters()
If Len(strTemp) = 0 Then
Cancel = True
strMsg = "No installed printers found."
Else
Me.cboPrinter.RowSource = strTemp
End If
باعتبار Me.cboPrinter هو اسم مربع التحرير في النموذج