+ Reply to Thread
Results 1 to 3 of 3

VBA Code Help

Hybrid View

  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

  2. #2
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: VBA Code Help

    That code creates buttons on a toolbar called "IPG". Doesn't move data

  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

    Hi rachaelgoldman1

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE CHANGE YOUR THREAD TITLE!!!
    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.

+ Reply to 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