Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-11-2013, 01:05 PM
jamles12 jamles12 is offline How do I combine two different contentcontrolonexit macros? Windows 8 How do I combine two different contentcontrolonexit macros? Office 2007
Novice
How do I combine two different contentcontrolonexit macros?
 
Join Date: Nov 2013
Posts: 5
jamles12 is on a distinguished road
Default How do I combine two different contentcontrolonexit macros?

Thank you for any input as I am another newbie with little coding experience. I am creating a macro enabled template for use as a quote template for many different machine models. I have a contentcontrolonexit procedure to auto update two different fields. Then I have another contentcontrolonexit procedure to perform a different function elsewhere in the template but when I place them both in the vba editor together it gives me the error "Compile Error, Ambiquous Name Detected "Document_ContentControlOnExit" So how do I use both of them? I have verified that both work separately. Below is the the first part with the procedure and then the second with the same procedure that I need combined. Any help would be greatly appreciated.
Code:
Dim i As Long 
Private Type ListData 
    strsizey As String 
    strsizex As String 
End Type  
 
Private Sub Document_ContentControlOnExit(ByVal contentcontrol As contentcontrol, Cancel As Boolean) 
    Dim tData As ListData 
    If Application.Version < "14.0" Then Main.SetDeveloperTabActive 
    Select Case contentcontrol.Tag   
    Case Is = "SizeSeries" 
        tData = GetDataIII(contentcontrol) 
        With  ActiveDocument 
            With .SelectContentControlsByTitle("SizeY").Item(1) 
                .LockContents = False 
                .Range.Text = tData.strsizey 
                .LockContents = True 
            End With 
            With .SelectContentControlsByTitle("SizeX").Item(1) 
                .LockContents = False 
                .Range.Text = tData.strsizex 
                .LockContents = True 
            End With 
        End With 
    End Select 
lbl_Exit: 
    Exit Sub 
End Sub
 
Private Function GetOfficeCCforRow(rng, ccTitle) As Word.contentcontrol 
    Dim ccs As Word.ContentControls 
    Dim cc As Word.contentcontrol 
    Dim ccFound As Word.contentcontrol 
    Set ccs = rng.Parent.SelectContentControlsByTag(ccTitle) 
    For Each cc In ccs 
        If cc.Range.InRange(rng.Cells(2).Range) Then 
            Set ccFound = cc 
        End If 
    Next 
    Set GetOfficeCCforRow = ccFound 
End Function  
 
Private Function GetDataIII(ByRef oCCPassed) As ListData 
    Dim arrData() As String 
    For i = 1 To oCCPassed.DropdownListEntries.Count 
        If oCCPassed.Range.Text = oCCPassed.DropdownListEntries(i).Text Then 
            arrData() = Split(oCCPassed.DropdownListEntries(i).Value, "|") 
            Exit For 
        End If 
    Next i 
    On Error Goto Err_NoPick 
    GetDataIII.strsizey = arrData(0) 
    GetDataIII.strsizex = arrData(1) 
    Exit Function 
Err_NoPick: 
    GetDataIII.strsizey = "" 
    GetDataIII.strsizex = "" 
lbl_Exit: 
    Exit Function 
End Function
Here Is the code To add
Code:
Option Explicit
 
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) 
    Dim doc As Word.Document 
    Set doc = ContentControl.Parent 
    If ContentControl.Type = wdContentControlDropdownList Then 
        If InStr(ContentControl.Title, "Project Manager") <> 0 Then 
            Dim cellCC As Word.ContentControl 
            Dim officeCC As Word.ContentControl 
            Dim faxCC As Word.ContentControl 
            Dim rowRange As Word.Range          
            Set rowRange = ContentControl.Range.Rows(1).Range 
            Set officeCC = GetOfficeCCforRow(rowRange, "PhoneOffice") 
            Set cellCC = GetOfficeCCforRow(rowRange, "PhoneCell") 
            Set faxCC = GetOfficeCCforRow(rowRange, "PhoneFax") 
            Select Case ContentControl.Range.Text 
            Case "User1" 
                officeCC.Range.Text = "User1 office" 
                cellCC.Range.Text = "User1 cell" 
                faxCC.Range.Text = "User1 fax" 
            Case "User2" 
                officeCC.Range.Text = "User2 office" 
                cellCC.Range.Text = "User2 cell" 
                faxCC.Range.Text = "User2 fax" 
            Case "User3" 
                officeCC.Range.Text = "User3 office" 
                cellCC.Range.Text = "User3 cell" 
                faxCC.Range.Text = "User3 fax" 
            End Select 
        End If 
    End If 
End Sub 
 
Private Function GetOfficeCCforRow(rng, ccTitle) As Word.ContentControl 
    Dim ccs As Word.ContentControls 
    Dim cc As Word.ContentControl 
    Dim ccFound As Word.ContentControl 
    Set ccs = rng.Parent.SelectContentControlsByTag(ccTitle) 
    For Each cc In ccs 
        If cc.Range.InRange(rng.Cells(2).Range) Then 
            Set ccFound = cc 
        End If 
    Next 
    Set GetOfficeCCforRow = ccFound 
End Function


Last edited by macropod; 11-11-2013 at 11:03 PM. Reason: Added code tags & formatting
Reply With Quote
 

Tags
macro problem, macropod, word 2007



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to combine many paragraphs in one paragraph? Jamal NUMAN Word 25 03-08-2013 04:31 AM
How do I combine two different contentcontrolonexit macros? Please help me to combine these code together lbf200n Word VBA 3 12-09-2012 04:22 PM
How do I combine two different contentcontrolonexit macros? Combine two forms into one lwisniewski Word VBA 3 12-24-2010 03:45 PM
How do I combine two different contentcontrolonexit macros? Combine pst files? markg2 Outlook 2 04-26-2010 03:09 PM
How do you combine two contact folders? waikoloavrm Outlook 0 04-12-2010 02:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft