View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] liu_jz@yahoo.com is offline
external usenet poster
 
Posts: 2
Default Excel 2007 Copy or AutoFill issue

In Excel 2007 SP1, I want to copy a range with a picture using VBA.
The following is the VBA code. There is a picture at cells D1:D3. I
used Copy or AutoFill method to copy the range. When I ran this code,
the cells was copied 4 times correctly. But the picture was copied
only 1 time. I tried this code in Excel 2000 - 2003, it is correct.
What is the problem? Is it a bug of Excel 2007?

Best regards,
Liu Jianzhong


Sub test()
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet

'Get Excel sheet
On Error GoTo llExcelSheetErr
Set xlWorkBook = ActiveWorkbook
Set xlWorkSheet = xlWorkBook.Worksheets("Sheet1")
xlWorkSheet.Range("5:20").Insert xlShiftDown
' xlWorkSheet.Range("1:4").AutoFill xlWorkSheet.Range("1:20"),
xlFillCopy
xlWorkSheet.Range("1:4").Copy xlWorkSheet.Range("5:20")
Exit Sub

llExcelSheetErr:
Call MsgBox(Err.Description, vbExclamation, "VBA Test")
End Sub