Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2015, 10:02 AM
ksigcajun ksigcajun is offline Compile error in Module Windows 7 64bit Compile error in Module Office 2010 64bit
Advanced Beginner
Compile error in Module
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default Compile error in Module

Not sure what's going on, but the code was working fine yesterday. Now today I receive the following error message.

"Compile error in hidden module: Module1
This error commonly occurs when code is incompatible with the version, platform or architecture of this application."

Here is my code to add a new row in a table. It errors out on the very last Msg Box.

PHP Code:
Option Explicit
Public p_oTargetRow As Word.Row
Sub InsertRowWithContent
()
Dim vProtectionType As VariantstrPassword As String
Dim oRows 
As Word.Row
Dim iRow 
As Long
Dim oRng 
As Word.Range
Dim lngIndex 
As Long
Dim strLocked 
As String
Dim arrLocked
() As String


Dim oCC_Master 
As ContentControloCC_Clone As ContentControl
 
  vProtectionType 
ActiveDocument.ProtectionType
  On Error Resume Next
  Set oRows 
p_oTargetRow
  
If Error <> 0 Then
    
If Selection.Information(wdWithInTableThen
        Set oRows 
Selection.Rows(1)
    
End If
  
End If
  If 
Not oRows Is Nothing Then
    Application
.ScreenUpdating False
      
If vProtectionType <> wdNoProtection Then
        strPassword 
"" 
        
ActiveDocument.Unprotect Password:=strPassword
      End 
If
      
With Selection
        iRow 
oRows.Index
        With 
.Tables(1)
          If .
Rows.Count iRow Then
            iRow 
iRow 1
            oRows
.Range.Copy
            
For Each oCC_Master In .Rows(iRow).Range.ContentControls
              strLocked 
oCC_Master.LockContentControl ","
              
oCC_Master.LockContentControl False
            Next oCC_Master
            strLocked 
Left(strLockedLen(strLocked) - 1)
            .
Rows.Add .Rows(iRow)
            
Set oRng = .Rows(iRow).Range
            oRng
.MoveEnd wdCharacter, -1
            oRng
.Paste
            arrLocked 
Split(strLocked",")
            For 
lngIndex 1 To UBound(arrLocked)
              .
Rows(iRow).Range.ContentControls(lngIndex 1).LockContentControl arrLocked(lngIndex)
            
Next lngIndex
          
Else
                        .
Rows.Last.Range.Copy
                        
.Rows.Add
            Set oRng 
= .Rows.Last.Range
                        oRng
.MoveEnd wdCharacter, -1
                     oRng
.Paste
            iRow 
iRow 1
          End 
If
                    
With .Rows(iRow)
            For 
lngIndex 1 To .Previous.Range.ContentControls.Count
              Set oCC_Master 
= .Previous.Range.ContentControls(lngIndex)
              
Set oCC_Clone = .Range.ContentControls(lngIndex)
              
With oCC_Clone
                
#If VBA7 Then
                  
If Int(Application.Version) >= 14 Then
                    
If .Type wdContentControlCheckBox Then
                      
.Checked False
                    End 
If
                  
End If
                
#End If
                
If .Type wdContentControlRichText Or _
                   
.Type wdContentControlText Or _
                   
.Type wdContentControlDate Then
                     
If Not .ShowingPlaceholderText Then
                       
.Range.Text ""
                     
End If
                
End If
                If .
Type wdContentControlDropdownList Or .Type wdContentControlComboBox Then
                  
.DropdownListEntries(1).Select
                End 
If
                If .
Type wdContentControlPicture Then
                  
If Not .ShowingPlaceholderText Then
                    
If .Range.InlineShapes.Count 0 Then
                      
.Range.InlineShapes(1).Delete
                      
.Range.InlineShapes(1).Width oCC_Master.Range.InlineShapes(1).Width
                    End 
If
                  
End If
                
End If
                If .
Type wdContentControlDate Then .Range.Text ""
                
.LockContentControl oCC_Master.LockContentControl
              End With
            Next lngIndex
          End With
        End With
      End With
      
If vProtectionType > -1 Then
         ActiveDocument
.Protect Type:=vProtectionTypePassword:=strPassword
      End 
If
      
Application.ScreenUpdating False
      Set p_oTargetRow 
Nothing
  
Else
      
MsgBox "The cursor must be locate in a table row containing content controls."_
              vbInformation vbOKOnly
"INVALID SELECTION"
  
End If
End Sub 
Reply With Quote
  #2  
Old 04-07-2015, 06:46 PM
gmaxey gmaxey is offline Compile error in Module Windows 7 32bit Compile error in Module Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Your code works fine here. You are missing the "+" between vbInformation and vbOkOnly.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 04-08-2015, 06:44 AM
ksigcajun ksigcajun is offline Compile error in Module Windows 7 64bit Compile error in Module Office 2010 64bit
Advanced Beginner
Compile error in Module
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
Your code works fine here. You are missing the "+" between vbInformation and vbOkOnly.
Once again, you're correct! Thanks for the help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error in Module FileSystemObject Compile Error: User-Defined Type Not Defined gsrikanth Excel Programming 2 03-28-2022 06:32 AM
compile error in save code tintin007 Word VBA 8 11-18-2014 03:49 AM
AZWizard Module - ?hidden module pcaldwell Word 1 08-22-2012 01:19 PM
Compile error: sub or function not defined.. xena2305 Excel Programming 0 08-02-2011 10:17 AM
compile error in Word raco Word 0 09-28-2010 12:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:24 AM.


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