Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error 438 on SetFocus

Posted on 2016-08-28
5
Medium Priority
?
55 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 22

Accepted Solution

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

Assisted Solution

by:Martin Liss
Martin Liss earned 1000 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 22
ID: 41773763
if these are range names:
Application.Goto Reference:="rangename"

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

885 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