Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy/Paste Problem
I'm trying to open a new WB, copy & paste values from the ActiveSheet
to the WB, then close & save the WB on the desktop. When I run this I get a run-time error '1004': "Copy method of Range class failed" and my copy/paste line is highlighted. Sub Test() Dim csFILENAME As String Dim wsh As Object Dim xlApp As Application Dim xlBook As Workbook Dim xlSheet As Worksheet Dim ws As Excel.Worksheet Set wsh = CreateObject("wscript.shell") csFILENAME = wsh.SpecialFolders.Item("Desktop") Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Add( Template:="Workbook") Set xlSheet = xlBook.Worksheets(1) xlSheet.Visible = True Set ws = ActiveSheet ws.Range("B3").Copy xlSheet.Range("A1") <<< This is highlighted xlBook.SaveAs (csFILENAME & "\" & "Test " & _ Format(Now(), "mm-dd-yy") & ".xls") xlBook.Close Set xlApp = Nothing End Sub Thanks, -- Dan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy and paste problem | Excel Discussion (Misc queries) | |||
Copy/ Paste Problem | Setting up and Configuration of Excel | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) | |||
Copy/Paste Problem | Excel Programming | |||
Copy/Paste Problem | Excel Programming |