Solved

Error 438 on SetFocus

Posted on 2016-08-28
5
31 Views
Last Modified: 2016-10-03
I am getting error code 438 with below code.

Private Sub Workbook_Open()

'On Error Resume Next
'Clipboard
    a = Application.ThisWorkbook.Path & "\" & "CIMSR339A.DBF"
    If Dir(a) <> "" Then
        Sheets(1).TPath.Text = a
        ActiveSheet.TName.SetFocus
    Else
        Sheets(1).TPath.Text = "Please browse the file."
        ActiveSheet.BRun.SetFocus
    End If

Dim DataObj As DataObject
Set DataObj = New DataObject

DataObj.GetFromClipboard

If Application.ClipboardFormats(1) = xlClipboardFormatText Then
    Sheets(1).TName.Text = DataObj.GetText(1)
    ActiveSheet.BRun.SetFocus
Else
    ActiveSheet.TName.SetFocus
End If

End Sub
0
Comment
Question by:Mukund Patel
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
crystal (strive4peace) - Microsoft MVP, Access earned 250 total points (awarded by participants)
ID: 41773712
what about using Select instead of SetFocus?
0
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points (awarded by participants)
ID: 41773760
Activate would be better than Select. Also your use of of TPath and TName are invalid.
0
 
LVL 20
ID: 41773763
if these are range names:
Application.Goto Reference:="rangename"

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question