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

شرح وافي لربط الاكسس بمنفذ الكوم بورت


Abdulkader 7

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

السلام عليكم اخواني هذا شرح وافي لعملية وصل منفذ الكوم بالاكسس وتطبيقاته مع مثال ,, ولا تنسونا من دعوة

بانتظار ردودكم ..........................

Port_Com_Test.rar

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

new1324778037%D8%B3%D9%88%D8%B1%D9%8A%D8%A9%202.jpg

االسلام عليكم اخواني بالنسبة لربط الاكسل بالسيريال كوم بورت كتالي

اانسخ الملف المرفق المسمى MSCOMM32.OCX الى العنوان التالي : C:\Windows\System\MSCOMM32.OCX

وقم بعد ذلك بتشغيل ملف التسجيل

اصبح لدينا الان اداة نقل بيانات فعالة بعد ذلك نذهب الى اكسل


Open up a new Excel workbook. Make sure you can see the 'Control Toolbox (View>>>Toolbars>>>Control Toolbox).

Rename your worksheet 'SerialPort'.

Once you can see the toolbox- there should be a little toolbox icon. Click the icon and select 'Microsoft Communication Control' from the list.

The cursor will change, allowing you to draw a box on the worksheet. This is the control. It does not matter where you place it - as when you open the workbook this will not be visible to the user.

Once you have created the control, right-click and select 'View Code'.

You should see something like -

Private Sub MSComm1_OnComm()

End Sub

This is the 'OnComm' event and tells excel what to do when data is received from the serial port. We will come back to this later. Lets write some code to open a port up....

Insert the following into a new sub under the OnComm sub -

Sub OpenPort()

'Open the COM Port with the relevant settings

Worksheets("SerialPort").MSComm1.CommPort = 1

Worksheets("SerialPort").MSComm1.Settings = "9600,n,8,1"

Worksheets("SerialPort").MSComm1.RThreshold = 1

Worksheets("SerialPort").MSComm1.InBufferSize = 4096

Worksheets("SerialPort").MSComm1.PortOpen = True


End Sub

The sub above will configure the port when you try and open it. 'CommPort' is the port number your device is connected to. 'Settings' are the device setting (baud rate, parity, etc) and are usually in the device documentation (you can also use the device with Hyperterminal to get these settings).

PortOpen = True tells Excel to open the port with the above settings.

RThreshold is what we are interested in here. By setting it to '1' we are telling Excel to fire the 'OnComm' code whenever data is received from the serial port.

The way I call the port open sub, is to have a worksheet onchange event. I only want the port to open when the user selects a cell in a particular column range, so I am using the following -

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Columns("A:A")) Is Nothing Then

If Target.Value = "" Then

Call OpenPort

End If

End If

Application.EnableEvents = True

End Sub

This piece of code must sit against the 'Worksheet' 'Selection Change' section. Use the dropdown boxes at the top of your VBA editor to select this.

So now, if a cell in column 'A' is selected, the port will be opened with my settings. As RThreshold is set to '1' - the OnComm code will be called whenever I try to read from the cheque reader and am in the 'A' column.

Now to tell it do something when data is received....

Go back to your OnComm make it look like -

Private Sub MSComm1_OnComm()

If Worksheets("SerialPort").MSComm1.CommEvent = comEvReceive Then

Call GetData

End If

End Sub

The CommEvent - comEvReceive tells Excel that if data is coming in from the serial device....do something. In this case, Call sub "GetData".

Now, to create sub "GetData" that will grab the information from the device and place it in your worksheet.

The sub below is very straightforward - but will help get you started!

Private Sub GetData()

Dim MyData As String

Wokrsheets("SerialPort").MSComm1.InputLen = 0

MyData = Worksheets("SerialPort").MSComm1.Input

ActiveCell.Value = MyData

MyData = ""

Worksheets("SerialPort").MSComm1.PortOpen = False

End Sub

The 'InputLen' setting tells Excel how much data to read from the serial device. Setting it to zero tells it to keep reading until the end of the file (ie it gets all of the data). If you know your string is always going to be 10 digits...you could set this to 10. Or you may need a function to pull the characters one at a time until you get to a specific value. It all depends on the device and what you are trying to achieve....

And you are done! You should now have a very basic working script to read data from a serial device and place it into your worksheet.

I hope this helps someone....my apologies for any poor terminology/lack of clarity and any mistakes I have made. I am not using the same code myself...and there is a great deal more that you will need to learn to use MSComm effectively. It is also the first time I have put something together like this (but that's obvious :P)

Hopefully this is a start for anyone else who is struggling to get going with this.

Have fun!

هذا الموضوع باللغة الانكليزية وهو مشابه لخطوات الاكسس تقريبا ولكن لضيق الوقت قمت بوضعه على هذه الصيغة ولكثرة الطلب عليه وارجو من لديه الوقت ان يشرح الكود للاخوة الاعضاء او الانتضار حتى اقوم انا العبد لله برفعه مع مثال والله ولي التوفيق

Active_Excel_2003.rar

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

جزاك الله كل خير يا اخى اللهم احفظ شعب سوريا واهلها اللهم انصر المستضعفين فى سوريا

منتظر شرح الكود الكبير اوووووووووووووووووى دة

وياريت ترفق مثال لتوضيح اكثر

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

اخي الكريم يبدو ان لديك منفذ الكوم مشغول مع جهاز اخر او لا يوجد منفذ كوم بورت في الجهاز وارجو االتاكد من الخطوات التي قمت بشرحها سابقاً وسوف اتبع الموضوع معك لان الرسالة الضاهرة لديك تفيد بانه الفيجوال بيسك اكسس غير قادر على الربط مع منفذ الكوم او احتمال اخر وهو الاغلب ان الاداة الخاصة بالربط

لم تقم بنسخها الى العنوان التالي c:\windows\system32\

ثم تقوم بتشغيل اداة التسجيل في مسجل قيم النظام وهي في المرفقات ومنتظر ردك

لكن لا تنسى تشغيل الملف المرفق المسمى Reg_11

______________________ ((( Syria ))))__________________________

Reg_Objects.rar

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

  • 3 months later...

اخي العزيز Syria

شاكل لك جدا على هذه الموضوع القيم الذي لطالما كنت ابحث عنه في عدة منتديات...

ولكن الاسف لم يفلح معي...فاثناء محاول ادراج microsoft communication control from في النموذج تظهر لي رسالة انه هذه عنصر التحكم غير معتمد

على الرغم انني طبقت الخطوات الذي تفضلت بها نصيا.....

مرفق صوره من رسالة الخطا

شاكر لك جدا مره اخرى على هذا الموضوع

post-47238-0-33603200-1349763766_thumb.j

post-47238-0-33063200-1349763990_thumb.j

post-47238-0-74771000-1349763997_thumb.j

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

اخي الكريم

حصلت معلومه من الاستاذه زهرة بان الاداه Microsoft communication control غير مدعومه في الاصدارات الجديدة من اوفيس

هذه الاداه تدعم فقط اوفيس 2000 و اوفيس اكس بي

فانا الان ارغب في الحصول على رابط تحميل لهذا الاوفيس

حاولت كثير البحث عنه في جوجل لكن معظم الروابط غير صالحه ولا تعمل

شكرا جزيلا

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

  • 2 weeks later...

لقد وجدت الاصدار الخاص بالاوفيس 2002....وبالفعل تم ادراج الاداه microsoft communication control في النموذج بنجاح.

ولكن عندما محاول تجربة الكود لاخذ القراءة لم يفلح معي !!!!

لا ادري ما المشكلة .....علما ان المنفذ يعمل بشكل صحيح عند استخدام hyper terminal

ارجو الافاده مع الشكر الجزيل....

post-47238-0-78391800-1351583906_thumb.j

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

  • 2 months later...
  • 1 year later...

اخي الكريم

حصلت معلومه من الاستاذه زهرة بان الاداه Microsoft communication control غير مدعومه في الاصدارات الجديدة من اوفيس

هذه الاداه تدعم فقط اوفيس 2000 و اوفيس اكس بي

فانا الان ارغب في الحصول على رابط تحميل لهذا الاوفيس

 

حاولت كثير البحث عنه في جوجل لكن معظم الروابط غير صالحه ولا تعمل

شكرا جزيلا

 

 

انا كنت محتفظا بالاوفيس اكس بي ... دعني اتاكد

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

  • 1 year later...

للربط والفائدة !

http://www.officena.net/ib/index.php?showtopic=60965&hl=

تم تعديل بواسطه رمهان
  • Like 1
رابط هذا التعليق
شارك

  • 1 year later...

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