Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-25-2019, 10:23 AM
ubrielbryne ubrielbryne is offline error 91 object variable or with block variable not set Windows 10 error 91 object variable or with block variable not set Office 2016
Novice
error 91 object variable or with block variable not set
 
Join Date: Feb 2019
Posts: 2
ubrielbryne is on a distinguished road
Cool error 91 object variable or with block variable not set

Hello.

I helped to create a user macro in Word that 6 people in my office are using on their own network profiles with the same version and settings on all of the applications.
When I personally installed the macro for each of them, I tested it and it ran fine.
Now 3 out of six are getting the run-time error '91' object variable or with block variable not set.

The debug shows ElseIf Selection.Style = "H0" Then
to be the point of error.
I have copied the entire problematic sub below. Remember, on the same day, at the same time, the same macro and copies of the same document will run or error on different user profiles.

What do you all think? (Heads up, I am a noob to writing in and using VBA language so go easy on me.)

Sub SLRkeep()
Dim slranswer As String
Dim p As Paragraph


Dim prange As Range
Dim i As Integer
Dim scount As Integer

For Each p In ActiveDocument.Paragraphs
p.Range.Select
If InStr(Selection.Text, SPQRtext) Then
With Selection.Range
If .Sentences.Count > 3 Then
i = 2
scount = .Sentences.Count
Do Until i + 1 = scount
If InStr(.Sentences(i), SPQRtext) = False And _
InStr(.Sentences(i - 1), SPQRtext) = False And _
InStr(.Sentences(i + 1), SPQRtext) = False Then
.Sentences(i).Delete
i = i - 1
scount = scount - 1
End If
i = i + 1
Loop
End If
End With
ElseIf Selection.Style = "H0" Then

ElseIf Selection.Style = "H1a" Then

ElseIf Selection.Style = "H1b" Then

ElseIf Selection.Style = "H2" Then

ElseIf Selection.Style = "H3" Then

ElseIf Selection.Style = "H4" Then

ElseIf Selection.Style = "H5" Then

Else
Selection.Delete
End If
Next p

End Sub
Reply With Quote
  #2  
Old 02-25-2019, 11:15 AM
ubrielbryne ubrielbryne is offline error 91 object variable or with block variable not set Windows 10 error 91 object variable or with block variable not set Office 2016
Novice
error 91 object variable or with block variable not set
 
Join Date: Feb 2019
Posts: 2
ubrielbryne is on a distinguished road
Default Solved

In-house tech had a stroke of genius and realized that we use alot of hidden text/variable style features in our documents. Show hidden text selection is a requirement for some of the parts of the whole macro to run correctly.

So, turning on the show hidden text option for the document makes the variables for the styles and other hidden text properties available for the macro to utilize.

YAY!
Reply With Quote
Reply

Tags
microsoft word, run-time 91, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Variable or With block variable not set Raza Excel Programming 8 01-15-2015 12:19 AM
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge Berryblue Mail Merge 1 11-13-2014 05:36 PM
error 91 object variable or with block variable not set Run-time error 91 object variable or with block variable not set JUST ME Word VBA 4 03-25-2014 06:56 AM
error 91 object variable or with block variable not set object variable or with block variable not set MJP143 Excel 1 02-11-2013 05:07 AM
error 91 object variable or with block variable not set Run-time error '91': Object variable or With block variable not set tinfanide Excel Programming 2 06-10-2012 10:17 AM

Other Forums: Access Forums

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