NickS1965
04-05-2012, 10:59 AM
I'm hoping that someone can help me... I'm trying to develop a Word Document to assist a colleague with Dyslexia. She finds it easier to read an on-screen document if the background is pale pink and the text is dark blue. I have created a Word Doc in Word 2003 (the version at work) which has the following code:
Private Sub clickMe_Click()
Dim MyA, MyB, MyC, MyD, MyE, MyF As Integer
Dim dlgOpen As FileDialog
'Open the File Dialog Box to allow a file to be selected
Set dlgOpen = Application.FileDialog(FileDialogType:=msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.Show
.Execute
End With
'Collect colour values from the master version
'MyA to MyC are the background colours
MyA = txtA.Value
MyB = txtB.Value
MyC = txtC.Value
'MyD to MyF are the Font colours
MyD = txtD.Value
MyE = txtE.Value
MyF = txtF.Value
'Select the whole text from the document
Selection.WholeStory
'Set the font color to the master version
Selection.Font.Color = RGB(MyD, MyE, MyF)
Selection.Font.Size = 14
Selection.Font.Name = "Arial"
Selection.HomeKey Unit:=wdStory
'Set the Active Document Background Color to the master version
ActiveDocument.Background.Fill.ForeColor.RGB = RGB(MyA, MyB, MyC)
ActiveDocument.Background.Fill.Visible = msoTrue
ActiveDocument.Background.Fill.Solid
End Sub
This allows the user to click on a button, select the file she wants to open from her drives, and theoretically it opens the document with the altered standard colored text and background color.
Except it doesn't always do it... Sometimes the text changes and the background stays the same.
In those cases (the background always changes in Web Layout, but we want it in Print Layout) to get it to work, you have to alter the background color manually and then press Ctrl+Z to "undo" and then the chosen salmon pink color appears as if by magic.
Can anybody help me please. She is already finding the assist of great help, but it could be better if it worked as required every time.
Regards,
Nick
Private Sub clickMe_Click()
Dim MyA, MyB, MyC, MyD, MyE, MyF As Integer
Dim dlgOpen As FileDialog
'Open the File Dialog Box to allow a file to be selected
Set dlgOpen = Application.FileDialog(FileDialogType:=msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.Show
.Execute
End With
'Collect colour values from the master version
'MyA to MyC are the background colours
MyA = txtA.Value
MyB = txtB.Value
MyC = txtC.Value
'MyD to MyF are the Font colours
MyD = txtD.Value
MyE = txtE.Value
MyF = txtF.Value
'Select the whole text from the document
Selection.WholeStory
'Set the font color to the master version
Selection.Font.Color = RGB(MyD, MyE, MyF)
Selection.Font.Size = 14
Selection.Font.Name = "Arial"
Selection.HomeKey Unit:=wdStory
'Set the Active Document Background Color to the master version
ActiveDocument.Background.Fill.ForeColor.RGB = RGB(MyA, MyB, MyC)
ActiveDocument.Background.Fill.Visible = msoTrue
ActiveDocument.Background.Fill.Solid
End Sub
This allows the user to click on a button, select the file she wants to open from her drives, and theoretically it opens the document with the altered standard colored text and background color.
Except it doesn't always do it... Sometimes the text changes and the background stays the same.
In those cases (the background always changes in Web Layout, but we want it in Print Layout) to get it to work, you have to alter the background color manually and then press Ctrl+Z to "undo" and then the chosen salmon pink color appears as if by magic.
Can anybody help me please. She is already finding the assist of great help, but it could be better if it worked as required every time.
Regards,
Nick