Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel 2007 Copy or AutoFill issue

The picture was not copied. A picture is not part of the cell structure it
is only an object that sits ontop of the cells and does not get copied. You
need to copy the picture and then place the copy at a new location.

Set MyPicture = ActiveSheet.Pictures("PictureofLincoln")
MyPicture.Copy
ActiveSheet.Paste
Set newpicture = Selection
newpicture.Top = Range("B7").Top
newpicture.Left = Range("B7").Left

" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using autofill in Excel 2007 Debs1967 Excel Discussion (Misc queries) 1 July 14th 09 01:20 PM
Copy and Paste Issue 2007 SP1 Tim Excel Discussion (Misc queries) 2 March 21st 09 01:45 PM
Office 2007 Copy Paste Issue anshuman Excel Discussion (Misc queries) 5 August 18th 07 09:38 PM
Office 2007 Filter Copy Issue anshuman Excel Programming 0 August 18th 07 08:08 AM
autofill issue Arain Excel Discussion (Misc queries) 0 March 28th 07 01:02 AM


All times are GMT +1. The time now is 11:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"