none
hyperterminal - vba acess RRS feed

  • Question

  • I have a barcode printer which I am connecting and programming it through hyperterminal. I am trying to access the hyperterminal from VBA (MS Access) I am currently opening the hyperterminal from VBA, but I also want to send text/commands from VBA to hyperterminal.

    Primarly I have created a blank .ht file with connection and settings and made a copy of it from VBA...now I want to edit the new copied .ht file from VBA

    This is what I have so far:

    'Location of file that has all the connections settings and main settings
    oldFile = "C:\Documents and Settings\~~~j~~~\Desktop\barcode.ht"
    
    'Location and name where the new file is saved.
    newFile = "C:\Documents and Settings\~~~j~~~\Desktop\new_barcode.ht"
    
    'Opening hyperterminal.exe
    hyperterminal = "C:\Program Files\Windows NT\hypertrm.exe"
    
    'Copy blank HT file (HT file is copied with the connection and settings set)
    FileCopy oldFile, newFile
    
    'Open file in hyperterminal
    Shell hyperterminal & " " & newFile, vbMaximizedFocus
    Shell "C:\Program Files\Windows NT\hypertrm.exe " & newFile, vbMaximizedFocus

    Thank you :)

    Thursday, July 12, 2012 7:05 AM

Answers

  • To edit file you can use Open,Print,Write methods or can access through FileSysteObject's TextStream object.

    And if you want to control the connection then you have to see whether it supports COM automation and creating the hyperterminal object by CreateObject.

    If not supported the you can try SendKeys as last resort.

    ---------------------------------------------------------------------------------------------

    Please do not forget to click “Vote as Helpful” if any post helps you and Mark as Answer if it solves the issue.

    • Marked as answer by joj091 Thursday, July 12, 2012 9:52 AM
    Thursday, July 12, 2012 7:37 AM
    Answerer

All replies

  • To edit file you can use Open,Print,Write methods or can access through FileSysteObject's TextStream object.

    And if you want to control the connection then you have to see whether it supports COM automation and creating the hyperterminal object by CreateObject.

    If not supported the you can try SendKeys as last resort.

    ---------------------------------------------------------------------------------------------

    Please do not forget to click “Vote as Helpful” if any post helps you and Mark as Answer if it solves the issue.

    • Marked as answer by joj091 Thursday, July 12, 2012 9:52 AM
    Thursday, July 12, 2012 7:37 AM
    Answerer
  • Are Open,Print Write methods ready in VBA? I wonder if you can show me some sample code to lead me cause I am totally lost! :/

    Also, to send commands to printer from hyperterminal the final command should be 'E' and one should press 'ENTER' to start sending the commands.....Is there a way that I can use the 'ENTER' button command??

    Thursday, July 12, 2012 9:05 AM
  • Hmmm.

    http://www.applecore99.com/gen/gen029.asp

    In Excel/Word press Alt+F11 .The VB editor will open.In extreme topleft one text box with text "Type a question for help".enter print and press enter.One result will be print statement.

    Or you can refer Internet also.

    But these statement will allow you write/read but not sending keystokes.

    Thursday, July 12, 2012 9:47 AM
    Answerer
  • I finally managed to work it out..... I used SendKeys through out, to write in the hyperterminal and to send command to printer using 'ENTER'

    Thank you for you time :D

    Thursday, July 12, 2012 9:51 AM