اذهب الي المحتوي
أوفيسنا

Application.ActivePrinter يعمل مع أكسل 2007 ولا يعمل مع 2010


yasayd

الردود الموصى بها

السلام عليكم 

 

 

كما  هو مشار إليه في العنوان    عندما أعمل  VBA   فإن    Application.ActivePrinter تعمل  بسهولة  في أكسل  2007 

بينما  نفسها  لا تعمل  عندما أستخدمها  مع أكسل 2010

 

 

وظيفتها   تفعل  طابعة  محددة مسبقاً    لطباعة  ورقة العمل  

 

يتم كتابتها كالمثال التالي : - 

 

Application.ActivePrinter = "HP LaserJet 4 local on LPT1:"

حيث أن ( HP LaserJet 4 local )  هو إسم الطابعة 

و  ( : on LPT1 ) هو المنفذ الذي  تعمل  عليه  الطابعة  في جهازك 

 

 

* حتى إذا قمت  بتسجيل ماكرو  في أكسل  2007   والذهاب إلى طباعة ثم إختيار الطابعة  فإن  هذا الكود  سيظهركما هو مكتوب في المثال السابق 

 

 

بينما  إذا  قمت  بنفس العمل  وسجلت ما كرو  في  أكسل  2010 وذهبت إلى طباعة  ثم أخترت إحدى الطابعات وضغطت على أمر طباعة  فإن هذا  الكود  لن يظهر إطلاقاً وفقط  سيظهر  أنك  أخترت طباعة الصفحات من كذا إلى كذا في ورقة العمل 

 

 

 

المطلوب  : 

 

    هل  هنالك   طريقة  ما   لتفعيل  الكود Application.ActivePrinter  وجعله   يؤدي وظيفته ؟

أم   

هل هنالك   كود  آخر    يؤدي   نفس   الوظيفة  ؟

 

 

 

 

*  ألتمس منكم  العذر  فإني مُبتدئ  في الأكسل  ولم أدرسه  ولم آخذ فيه  أي  دورات بل  دخلت  على النت شاهدت بعض الدروس في اليوتيوب  

       لذا  ربما  تكون  تعابيري  ليست  دقيقة   فلست من أهل هذا التخصص . 

       

تم تعديل بواسطه yasayd
رابط هذا التعليق
شارك

Sub Test()
    Dim strPntName As String
    
    strPntName = MatchFullNetworkPrinterName("HP LaserJet Professional P1102", True)
    If strPntName <> "" Then MsgBox "The Active Printer Has Been Changed Successfully!", vbOKOnly, "Tips"
End Sub

Function MatchFullNetworkPrinterName(ByVal strNetworkPrinterName As String, Optional ByVal blnToChange As Boolean = False) As String
    Dim strCurrentPrinterName   As String
    Dim strTempPrinterName      As String
    Dim i                       As Long

    strCurrentPrinterName = Application.ActivePrinter
    i = 0

    Do While i < 100
        strTempPrinterName = strNetworkPrinterName & " on Ne" & Format(i, "00") & ":"

        On Error Resume Next
            Application.ActivePrinter = strTempPrinterName
        On Error GoTo 0

        If Application.ActivePrinter = strTempPrinterName Then
            MatchFullNetworkPrinterName = strTempPrinterName
            Exit Do
        End If
        i = i + 1
    Loop

    If Not blnToChange Then Application.ActivePrinter = strCurrentPrinterName
End Function

 

  • Like 1
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information