Questions

VBA Excel Help

+
0 Votes
Locked

VBA Excel Help

rimap1
I am having trouble selecting a cell using VBA code so I can paste data from another application/workbook. I think its a downfall of VBA-Excel because I have had this trouble before. Below is my code. Does anyone know how to get around it.

Set MyXL = GetObject("C:\Documents and Settings\rimap\Desktop\NIMO PI\plugNchugNIMO.xls")

' Show Microsoft Excel through its Application property. Then
' show the actual window containing the file using the Windows
' collection of the MyXL object reference.
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True
'Do manipulations of your file here.
MyXL.Activate
MyXL.Sheets("PIbatchPaste").Activate
MyXL.Sheets("PIBatchPaste").Cells.ClearContents

' this is where I have my trouble... it doesn't paste!
MyXL.ActiveSheet.Range("A1").Select
Selection.Paste


Thanks