![]() |
#1
|
|||
|
|||
![]() here is the code, i am using Step through in the debugger, when i get to .Select it says, "Cant Execute in Break Mode" . it actually stills selects the sentence and I can continue but still displays this error msg. I would like to select the sentence, to visually track the changes. Anyway to fix this issue? thanks Code:
If do_DocVars_Exist = 1 Then sentNumb = ActiveDocument.Variables("selNumb").Value Set prevSent = doc.Sentences(sentNumb) With prevSent .Select .Font.Size = ActiveDocument.Variables("selSize").Value .Font.Color = ActiveDocument.Variables("selColor").Value .Font.Name = ActiveDocument.Variables("selName").Value End With End If |
#2
|
||||
|
||||
![]()
Without the rest of the code, anyone trying to assist is flying blind. I think I understand the concept of what the macro is doing and the following will do that provided the values in the variables are appropriate:
Code:
Option Explicit Sub Macro1() Dim prevSent As Range Dim sentNumb As Long If do_DocVars_Exist = True Then sentNumb = ActiveDocument.Variables("selNumb").Value If ActiveDocument.Sentences.Count >= sentNumb Then Set prevSent = ActiveDocument.Sentences(sentNumb) With prevSent .Select .Font.Size = ActiveDocument.Variables("selSize").Value .Font.Color = ActiveDocument.Variables("selColor").Value .Font.Name = ActiveDocument.Variables("selName").Value End With Else MsgBox "There is no sentence number " & sentNumb End If Else MsgBox "The required variables are not present" End If End Sub Function do_DocVars_Exist() As Boolean Dim oVar As Variable Dim iVar As Integer: iVar = 0 For Each oVar In ActiveDocument.Variables Select Case oVar.Name Case "selNumb", "selSize", "selColor" If IsNumeric(oVar.Value) Then iVar = iVar + 1 End If Case "selName" iVar = iVar + 1 End Select Next oVar If iVar = 4 Then do_DocVars_Exist = True End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
the gmayor
but the only question i had was why does the display a msgbox saying "Cannot Execute in Break Mode" once it executes the line with .Select the code continues with no problems (meaning there really is not effect to "Cannot execute in Break Mode") it almost seems like a bug to me. why wouldnt i be able to .Select a sentence? Why would it display this message? why would the code be able to continue without any issues and still .Select the sentence... thks for the reply |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Why are Portrait mode JPG Images changed to landscape mode | KHH0725 | PowerPoint | 0 | 02-22-2017 01:51 PM |
Microsoft Office Word Online Text Space is Different in Reading Mode from When it's in Editing Mode | darkjanggo | Word | 1 | 12-15-2015 05:06 PM |
![]() |
moggymiaow | Word VBA | 4 | 10-10-2013 04:01 PM |
paragaph hard break, soft break and ...strange break | czomberzdaniela | Word | 2 | 12-03-2010 06:58 PM |
![]() |
prg4hire | Word | 2 | 09-25-2010 09:46 AM |