Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2004, 12:46 AM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copying controls from Excel Sheet

Hi
I am facing some problem in copying controls on excel sheet.
I have used
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

This function copy only the content and not the controls.
I don't wanna use copy method because it copies the entire sheet with formulae, image and button.
Please suggest me some alternative.

Regards,
Gaurav

 
Old June 27th, 2004, 11:10 AM
Authorized User
 
Join Date: Aug 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Suggest you place controls on a toolbar rather than on the worksheet itself.


 
Old June 27th, 2004, 12:29 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried this one - got it with the macroeditor!
I expect you should set a reference to Microsoft Forms x.x Object Library under Tools-References.

   ActiveSheet.Shapes("CommandButton1").Select
    Selection.Copy
    Range("I28").Select
    ActiveSheet.PasteSpecial Format:="Microsoft Forms 2.0 CommandButton-objekt", _
        Link:=False, DisplayAsIcon:=False
 
Old June 27th, 2004, 02:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you know you don't want to copy e.g. comments, but all other shapes on the sheet, try this one:

Sub MoveControls()
Dim sh As Shape
Dim T, L As Integer

Sheets("Sheet1").Select
    For Each sh In ActiveSheet.Shapes
    If sh.Type <> msoComment Then
        T = sh.Top
        L = sh.Left
        sh.Copy
            Sheets("Sheet2").Select
                ActiveSheet.PasteSpecial Format:="Microsoft Forms 2.0 CommandButton-objekt", _
                Link:=False, DisplayAsIcon:=False
        sh.Select
        Selection.Top = T
        Selection.Left = L
    End If

    Sheets("Sheet1").Select
    Next
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying code from one sheet to another jdd0x01 Excel VBA 0 May 28th, 2007 07:11 PM
Copying Xl sheet from one Xl file to another kesavan Excel VBA 1 July 3rd, 2006 10:11 PM
write multi-sheet Excel w/o Excel.Application manmoth Classic ASP Components 2 November 22nd, 2005 10:56 AM
copying an excel list balllian Excel VBA 2 October 15th, 2004 02:54 AM
Copying controls at run time aspadda Excel VBA 0 November 12th, 2003 01:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.