Results 1 to 1 of 1

VBA, EXCEL: Pasting Image Shape Causes Some Merged Cells to Unmerge

Threaded View

  1. #1
    Registered User
    Join Date
    04-12-2011
    Location
    San Jose, California
    MS-Off Ver
    Excel 2003
    Posts
    17

    VBA, EXCEL: Pasting Image Shape Causes Some Merged Cells to Unmerge

    Greetings:

    I have a routine that allows the User to select a gif file (using: Application.GetOpenFilename) which is the dimensioned and placed on
    the 'MAIN SHEET'. After the new logo image has been selected and placed on the 'MAIN SHEET', it is copied and then pasted on 'ANOTHER
    SHEET'; the following code applies:

    	'REMOVE PRIOR INSTANCE OF 'imgLogo' IF ONE EXISTS ON 'ANOTHER SHEET'
    		tmpID = ActiveWorkbook.Sheets("ANOTHER SHEET").Shapes("imgLogo").ID
    			If Not IsEmpty(tmpID) Then 
    				'Do if prior 'imgLogo' exists
    				ActiveWorkbook.Sheets("ANOTHER SHEET").Shapes("imgLogo").Select
    				Selection.Delete
    			End If
    
    	'COPY LOGO SHAPE	
    		ActiveWorkbook.Sheets("MAIN SHEET").Shapes("newLogo").Copy
    
    	'PASTE LOGO TO ANOTHER PAGE
    		ActiveWorkbook.Sheets("ANOTHER SHEET").Range("A1").Paste 'NOTE: CELL A1 IS NOT IN A MERGED RANGE
    
    	'NAME THE PASTED SHAPE
    		Selection.Name = "imgLogo"
    
    	'RELOCATE THE SHAPE
    		ActiveWorkbook.Sheets("ANOTHER SHEET").Shapes(Selection.Name).Left = 3 'Place Horizontally
    		ActiveWorkbook.Sheets("ANOTHER SHEET").Shapes(Selection.Name).Top = 30 ' Place vertically
    
    	'RETURN FOCUS TO 'MAIN SHEET'	
    		ActiveWorkbook.Sheets("MAIN SHEET").Select


    The problem I am experiencing is that a few of the worksheets to which I am pasting this picture shape have merged cells, however none
    located where I desire 'imgLogo' to be placed. FRequently, I get a warning dialog saying 'This operation will cause some merged cells to
    unmerge
    ' (See screen shot)

    To attempt to overcome this, I have added a Range reference 'A1' (cell not in a merged range) to the Paste command in hopes that by doing
    so, the pasted shape will not first be pasted in a merged range.

    It is important to note that when opting to proceed (OK) after encountering the warning dialog, the logo shape does relocate as shown in
    the above code ('RELOCATE THE SHAPE).
    Attached Images Attached Images
    Last edited by lhasha; 06-23-2016 at 03:02 PM. Reason: typo

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Pasting an image into selected merged cells. VBA to size automatically to selected range
    By DCC_PD in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2015, 09:57 AM
  2. automatically fit an image into merged cells for full width of merged cells
    By Marcin4111 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-18-2014, 03:12 PM
  3. VBA to insert a photo into merged cells or shape and compress image size
    By nwb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2014, 03:10 AM
  4. Unmerge merged cell and put value in all cells
    By sa02000 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-09-2012, 08:31 AM
  5. VBA code to search all merged cells and then unmerge them filling them with values
    By Blasphemer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-17-2012, 09:37 AM
  6. Replies: 1
    Last Post: 08-20-2006, 04:15 AM
  7. Spreadsheet with merged cells - how can I unmerge the cell and re.
    By Dotgale2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2005, 10:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1