Closed Thread
Results 1 to 4 of 4

VBA Code Help

  1. #1
    Registered User
    Join Date
    09-06-2013
    Location
    Champaign, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    VBA Code Help

    The Code below works perfectly except it will not move anything to the second tab that is beyond column M.. Can someone please help me fix it so that it cuts and pastes onto the second tab all the way to column S?



    Sub Auto_Open()
    Dim oToolbar As CommandBar
    Dim oButton As CommandBarButton
    Dim MyToolbar As String
    Dim oPic As stdole.IPictureDisp
    Dim oMask As stdole.IPictureDisp
    ' Give the toolbar a name
    MyToolbar = "IPG Toolbar"

    On Error Resume Next
    ' so that it doesn't stop on the next line if the toolbar's already there

    ' Create the toolbar; PowerPoint will error if it already exists
    Set oToolbar = CommandBars.Add(Name:=MyToolbar, Position:=msoBarTop, Temporary:=True)
    oToolbar.Protection = msoBarNoCustomize
    If Err.Number <> 0 Then
    ' The toolbar's already there, so we have nothing to do
    Exit Sub
    End If

    On Error GoTo ErrorHandler

    ' Now add a button to the new toolbar
    Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    ' And set some of the button's properties
    With oButton
    .FaceId = 6853
    .TooltipText = "IPG Non-Confidential"
    .Caption = "IPG &Non-Confidential"
    .OnAction = "Non"
    .Style = msoButtonIconAndCaption
    End With

    ' Now add a button to the new toolbar
    Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    ' And set some of the button's properties
    With oButton
    .FaceId = 6852
    .TooltipText = "IPG Green"
    .Caption = "IPG &Green"
    .OnAction = "Green"
    .Style = msoButtonIconAndCaption
    End With

    ' Now add a button to the new toolbar
    Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    ' And set some of the button's properties
    With oButton
    .FaceId = 6859
    .TooltipText = "IPG Yellow"
    .Caption = "IPG &Yellow"
    .OnAction = "Yellow"
    .Style = msoButtonIconAndCaption
    End With

    ' Now add a button to the new toolbar
    Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    ' And set some of the button's properties
    With oButton
    .FaceId = 6850
    .TooltipText = "IPG Red"
    .Caption = "IPG &Red"
    .OnAction = "Red"
    .Style = msoButtonIconAndCaption
    End With

    oToolbar.Visible = True

    NormalExit:
    Exit Sub ' so it doesn't go on to run the errorhandler code

    ErrorHandler:
    'Just in case there is an error
    MsgBox Err.Number & vbCrLf & Err.Description
    Resume NormalExit:
    End Sub
    Sub Non()
    IPG "Non-Confidential"
    End Sub

    Sub Green()
    IPG "Confidential Green"
    End Sub

    Sub Yellow()
    IPG "Confidential Yellow"
    End Sub

    Sub Red()
    IPG "Confidential Red"
    End Sub
    Sub IPG(classification)

    On Error Resume Next



    ActiveSheet.PageSetup.LeftFooter = "Caterpillar: " & classification


    End Sub
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Qu嶵ec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: VBA Code Help

    Hi,

    Please use code tags when posting code. (using the # button)

    Did you post the correct code????
    It looks like it's a code to add button to a toolbar, not to copy stuff from one tab to an other...
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Code Help

    Rachael, Rachael, Rachael

    This is a duplicate post and the Title has not been changed

    http://www.excelforum.com/excel-prog...code-help.html
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,908

    Re: VBA Code Help

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread. Thanks to jaslake for including a link to it above.

    Thread Closed.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2013, 04:30 AM
  2. Adding Text to another cell VB code (Help Tweeking code) (Excel 2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 11:37 AM
  3. Code for email alerts from excel isn't working, wrong code possibly?
    By jessthorogood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 01:45 AM
  4. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  5. Replies: 0
    Last Post: 10-06-2006, 09:05 AM

Tags for this Thread

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