0

I have a Textbox1, Label1 and a AcroPDF1. My goal is to use a barcode scanner and scan a material number. I don't have keybord or mouse available at that location. The barcode scanner gives a Enter asci at the end. That is fine but it makes it go to the next index. I tried everything not to jump to the AcroPDF but the Tabstop is already on false but it still jumps into the PDF. So I want to be able to scan at any time and a special pdf beeing displayed.

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
        If InStr(TextBox1.Value, "_") <> 0 Then
            TextBox1.Value = Left(TextBox1.Value, InStrRev(TextBox1.Value, "_", , vbTextCompare) - 1)
        End If
    Label1.Caption = TextBox1.Value
    TextBox1.Value = ""
    AcroPDF1.LoadFile "F:\APPS\Packaging\84260388.pdf"
End If
End Sub

Thanks

Patrik
  • 1
  • 1
  • 1

2 Answers2

0

not sure if I'm reading this correctly, but once the PDF is loaded you want to set focus back to the textbox? If thats the case, use the TextBox1.SetFocus() Method after your PDF Load. That will set the cursor back to the textbox.

Fink
  • 3,356
  • 19
  • 26
0

it is indeed not very clear how to set focus back to the form after activating axAcroPDF control. this problem is discussed in threads like this. there are 3 solutions offered, but they seem to me more like hacks, because axAcroPDF ActiveX control has in itself a rather unusual behavior. i am afraid that (finally) using this control with a complex and/or serious application is not a good idea.

Community
  • 1
  • 1
hello_earth
  • 1,442
  • 1
  • 25
  • 39
  • i myself finally used the Timer hack to return focus once the control has been activated. the thing in my case is that, even though the control seems to have a strange behaviour, it's still the fastest solution to display PDFs - the time to convert PDF to a GDI+ manageable image is quite significant (i used ImageMagick COM+ component) – hello_earth Apr 20 '12 at 15:19