Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can macro's refer to a setup (ini) file to define colors and categorie

Status
Not open for further replies.

AlexFeddes

Programmer
Jan 17, 2009
22
NL
I want to distribute a template (*.dot file) to enable people to automate certain tasks of marking selected text and extracting that to an overview in the document.

I have written certain code to color and add a symbol to selected text, then automatically placing this selected text in a section of the document with a category called "Hightlight (**)" - thereby trying to categorise notes that I glean from text.

I have received some feedback that people already use colorcoding and would like to use their own colors and categories instead of the ones I've defined - is there a way to use a setup document / file with definitions which colors and categories to use

A sample of the code for one categorie is as follows:
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorYellow
Selection.Font.ColorIndex = wdAuto
With Selection.Font
.Bold = True
End With

Dim Msg, Style, Title, Response, MyString
Msg = "Wilt u de geselecteerde text markeren EN kopiëren naar de sectie 'Studie overzicht'? Klik 'No' als u alleen de geselecteerde text wilt markeren."
Style = vbYesNo + vbDefaultButton1
Title = "Kopieer HIGHLIGHT naar Studie overzicht" '> Replace Word

Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then
Selection.Copy

Selection.Find.ClearFormatting
With Selection.Find
.Text = "Highlight (**)" '> Replace Word
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute

Selection.MoveUp Unit:=wdLine, Count:=1
' Selection.TypeText Text:=Chr(11) & Chr(11)
Selection.TypeParagraph
Selection.TypeParagraph
Selection.MoveUp Unit:=wdLine, Count:=1

Selection.PasteAndFormat (wdPasteDefault)


Else
Selection.MoveLeft Unit:=wdCharacter, Count:=1

'> Replace sectie
Selection.InsertSymbol Font:="Wingdings", CharacterNumber:=-4030, Unicode _
:=True
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Superscript = True
Selection.Font.Bold = True
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorYellow
Selection.Font.ColorIndex = wdAuto

Selection.MoveRight Unit:=wdCharacter, Count:=1
End If

The sections I want to refer to an ini file are:

Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorYellow
Selection.Font.ColorIndex = wdAuto

Selection.Find.ClearFormatting
With Selection.Find
.Text = "Highlight (**)"

Hope you understand my question.

Regards,
Alex
 
Hi,

Please post VBA questions in Forum707.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top