Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-06-2014, 12:37 PM
SuzeG SuzeG is offline VBA Run time error '91' suspect .placeholdertext=nothing Windows 7 64bit VBA Run time error '91' suspect .placeholdertext=nothing Office 2010 64bit
Novice
VBA Run time error '91' suspect .placeholdertext=nothing
 
Join Date: Dec 2013
Location: Va Beach
Posts: 21
SuzeG is on a distinguished road
Unhappy VBA Run time error '91' suspect .placeholdertext=nothing

I have created a form with multiple tables.
When it gets to this part of the code I get

Run Time Error '91'
Object variable or with block not set

I believe it is because the .placeholdertext = nothing



How can I fix this?

Thank you in advance
Code:
 
With ActiveDocument.Tables(6)
  If ContentControl.Range.InRange(.Range) Then
    For i = 3 To .Rows.Count
      With .Cell(i, 2).Range.ContentControls(1)
        If .Range.Text <> .PlaceholderText Then
          k = k + 1
          For j = 1 To .DropdownListEntries.Count
            If .DropdownListEntries(j) = .Range.Text Then
              l = l + .DropdownListEntries(j).Value
              Exit For
            End If
          Next
        End If
        i = i + 1
      End With
    Next
    With ActiveDocument.Tables(1).Rows.Last.Cells(1).Range
       If k > 0 Then
        .Text = Format(l, "##0")
       Else
         .Text = vbNullString
       End If
     End With
  End If
End With
Reply With Quote
  #2  
Old 03-06-2014, 02:12 PM
macropod's Avatar
macropod macropod is offline VBA Run time error '91' suspect .placeholdertext=nothing Windows 7 32bit VBA Run time error '91' suspect .placeholdertext=nothing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Are we to assume your ".placeholdertext = nothing" is the result of having used ".SetPlaceholderText , , """ somewhere? If so, that won't produce an error with the above code; neither would leaving the default placeholdertext in-situ.
Note also that, instead of "If .Range.Text <> .PlaceholderText Then" you could use "If .ShowingPlaceholderText = False Then"

It's not apparent to me where the error is occurring. You might do well to insert some message boxes into the code to return the values of your variables and text at various points so you can discover at what point in the process the code falls over.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-06-2014, 04:54 PM
SuzeG SuzeG is offline VBA Run time error '91' suspect .placeholdertext=nothing Windows 7 64bit VBA Run time error '91' suspect .placeholdertext=nothing Office 2010 64bit
Novice
VBA Run time error '91' suspect .placeholdertext=nothing
 
Join Date: Dec 2013
Location: Va Beach
Posts: 21
SuzeG is on a distinguished road
Default

Thank you Paul. The error was occurring in the 5th line of code. I changed the code to what you suggested and it seems to work fine.
Thank you again for your expertise.
Reply With Quote
Reply

Tags
runtime error 91, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error '1004' galkej Excel 0 02-03-2014 06:39 AM
Get Run-time Error 11 Jamtart PowerPoint 2 08-31-2012 05:04 AM
VBA Run time error '91' suspect .placeholdertext=nothing Run time error 1004 yonasan Excel Programming 3 06-12-2012 11:08 PM
Word Visual Basic error - run time error 504 crazymorton Word 11 01-13-2012 04:32 AM
VBA Run time error '91' suspect .placeholdertext=nothing Run-time error 438 cksm4 Word 2 01-12-2011 03:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:16 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