Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-28-2017, 07:33 AM
ilcaa72 ilcaa72 is offline Hold Previous Selecton Sentence variables Windows 7 64bit Hold Previous Selecton Sentence variables Office 2013
Novice
Hold Previous Selecton Sentence variables
 
Join Date: Jan 2014
Posts: 27
ilcaa72 is on a distinguished road
Default Hold Previous Selecton Sentence variables

hi, I am trying to create a easier way for me to read my Word docs, i have posted before on getting 1 line per sentence which is working, i also figured the way to increase the font size and color of the text for each sentence that my cursor is at, helps in my readings. But once i move up or down to next sentence, the text stays the increased size and color.

what is a method I can revert the previous sentence to its original size, color, font when I move away from it?

The document has different font sizes for Chapter Headings, Section Heading, Sub-Section headings, and Text which i want to maintain, so changing all text as 1 isn't an option. i know I can store the values of Font.Size, Color, Name into variables but how would i apply it to the previously selected sentence? thanks even if you can point me in a direction to explore some options...

the code runs as a WindowsSelectionChange()

Code:
Private Sub msWordApp_WindowSelectionChange(ByVal oSel As Selection)
    Dim doc As Document
    Dim paras As Paragraphs
    Dim para As Paragraph
    Dim sents As Sentences
    Dim sent As Range

    Set doc = ActiveDocument
    Set paras = doc.Paragraphs

    With Selection
        selSize = .Font.Size
        selColor = .Font.Color
        selName = .Font.Name

        .Sentences(1).Select
        .Font.Size = "20"
        .Font.ColorIndex = wdBlue

    End With 
end Sub

Reply With Quote
  #2  
Old 04-28-2017, 08:04 AM
ilcaa72 ilcaa72 is offline Hold Previous Selecton Sentence variables Windows 7 64bit Hold Previous Selecton Sentence variables Office 2013
Novice
Hold Previous Selecton Sentence variables
 
Join Date: Jan 2014
Posts: 27
ilcaa72 is on a distinguished road
Default

i did a little more investigating and found something called Document Variables. Variables that are 'stored' in the document once the Sub ends. I have been able to assign some Sentence property values to the variables like this...

Just want to check to see if anyone thinks this is a good/right approach?
Also, i encountered 2 issues...
1. When i run it again it errors, "Variable Name Exists" - so how do i destroy the variable name for reuse?
2. in a standalone Sub or in Immed Window, "ActiveDocument.Range(0, Selection.Range.End).Sentences.Count" returns the currently selected Sentence number. But when assigning it to this variable, its displays 0

any thought or assistance? thanks

Code:
 With x
        ActiveDocument.Variables.Add Name:="selSize", Value:=.Font.Size
        ActiveDocument.Variables.Add Name:="selColor", Value:=.Font.Color
        ActiveDocument.Variables.Add Name:="selName", Value:=.Font.Name
        ActiveDocument.Variables.Add Name:="selNumb", Value:=Sent_number = _ ActiveDocument.Range(0, Selection.Range.End).Sentences.Count
Reply With Quote
  #3  
Old 04-28-2017, 08:39 AM
ilcaa72 ilcaa72 is offline Hold Previous Selecton Sentence variables Windows 7 64bit Hold Previous Selecton Sentence variables Office 2013
Novice
Hold Previous Selecton Sentence variables
 
Join Date: Jan 2014
Posts: 27
ilcaa72 is on a distinguished road
Default

hello

i figured out both issues

1. destroy Document Variables
single by name:
ActiveDocument.Variables("FullName").Delete

All variables by loop:
For x = ActiveDocument.Variables.Count to 1 Step -1
ActiveDocument.Variables(x).Delete
Next x

2. Not returning correct Sentence Number. i entered the formula wrong, i actually assigned it, once removed it works

only outstanding issue is... Is this a solid way to achive my stated goal? thanks
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Timing Doesn't Hold yonargi2 PowerPoint 0 11-13-2015 03:15 PM
Array to iterate through variables and trap blank variables Marrick13 Word VBA 5 08-04-2015 06:19 AM
can word: make variables, find appropriate pages, fill out pages with variables, print only those 20GT Word VBA 1 10-15-2014 09:48 PM
Hold Previous Selecton Sentence variables Delete does not bring second sentence closer to first sentence Andoheb Word 29 07-03-2014 01:48 PM
Headers won't hold formatting leftylee Word 0 08-09-2010 01:13 PM

Other Forums: Access Forums

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