VBA - Error 438

galileogali

Well-known Member
Joined
Oct 14, 2005
Messages
748
This is my code (a piece)

Code:
Option Explicit
Sub CargarVariables()
Dim xlp As Object
Dim VAR As Variable
Dim wbk As Object
Dim wks As Object
Dim ActCell As Object
Dim ruta As String
Dim resp As Integer

Const xldown = -4121
Static regist As Variant

ruta = ThisDocument.Path & "\"
On Error Resume Next
Set xlp = GetObject(, "Excel.Application")
Err.Clear
On Error GoTo 0
If xlp Is Nothing Then
    Set xlp = CreateObject("Excel.Application")
End If
On Error Resume Next
Set wbk = xlp.Workbooks("Carga .xls")
Err.Clear
On Error GoTo 0
If wbk Is Nothing Then
xlp.Workbooks.Open ruta & "Carga .xls"
Set wbk = xlp.ActiveWorkbook
End If

Set wks = wbk.Sheets("Hoja1")
Set ActCell = wks.Range("A2")
ActCell.Activate
ActCell.End (xldown)


Excel from Word.
Without Reference to Excel Enabled

Why do I get an error 438 in this line?

Code:
ActCell.End (xldown)

xldown is defined in declarations
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I believe that since you are not returning a reference, Excel is expecting an action, .Select.

Also, if Hoja1 is not the active sheet when the wb was last saved and closed, the line before will foul. Try:
Code:
xlp.GoTo ActCell
ActCell.End(xldown).Select
 
Upvote 0
Thank you, very much

Comment "top secret":
It is incredible what small thing one can lock and not realize (jejejeje)

Thanks, again
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top