[mso] Re: Help with some Code in Word

  • From: "John Mon" <john82654@xxxxxxxxx>
  • To: mso@xxxxxxxxxxxxx
  • Date: Mon, 23 Apr 2007 11:36:41 -0400

Here'sa lady I know that teaches VBA. She has some free stuff on her site
and sells some other stuff. It's very well written. She also works for MS, I
think, LOL!
MouseTrax Computing
Solutions<http://www.mousetrax.com/Consulting_Solutions.html>

On 4/23/07, Chinell, David F (GE Indust, Security) <David.Chinell@xxxxxx>
wrote:
>
> Geoff:
>
> There's lots of advice here and in other lists about the best way to
> learn VBA. Here's the overview of how I learned -- not necessarily the
> best way, but one way.
>
> 1. I started by recording macros, then opening them up in the VBE
> (Alt+F11) and examining and altering the code there. The VBA help is
> actually helpful in its own way.
>
> 2. To get to the next level, I started browsing code snippets on the
> internet. The Word MVP site has lots of good code. You can learn by
> examining what's there. That will help you get your head around the Word
> document object and using object-oriented coding.
>
> 3. Next, I got a how-to book on writing VBA. That helped me organize
> what I was learning into a coherent scheme. At this point, I think
> another major breakthrough was learning how to use the VBE better, so as
> to be able to test code effectively, without having to "run it and see."
>
> You might make better progress if you got the book and learned how to
> use the VBE first, rather than later. But all the "dinking around" with
> recorded macros certainly helped me get started in a non-threatening
> way.
>
> Books I currently have:
>
> VB & VBA in a Nutshell by Lomax
> VBA Developers Handbook by Getz and Gilbert
> Writing Word Macros by Roman
> Word Hacks by Savikas
>
> I can't really give you a good evaluation of these books. I hope someone
> else can provide better guidance. I've only gotten them on someone
> else's recommendation, and use them mainly as reference material when
> I'm stuck. These lists are actually much better for that, though.
>
> As to your table code... When I recorded the action of applying a shade
> to a table cell, this is the resulting code:
>
> Sub x()
> '
> ' x Macro
> ' Macro recorded 4/23/2007 by David Chinell
> '
>    With Selection.Cells
>        With .Shading
>            .Texture =3D wdTextureNone
>            .ForegroundPatternColor =3D wdColorAutomatic
>            .BackgroundPatternColor =3D wdColorGold
>        End With
>        With .Borders(wdBorderLeft)
>            .LineStyle =3D wdLineStyleSingle
>            .LineWidth =3D wdLineWidth050pt
>            .Color =3D wdColorAutomatic
>        End With
>        With .Borders(wdBorderRight)
>            .LineStyle =3D wdLineStyleSingle
>            .LineWidth =3D wdLineWidth050pt
>            .Color =3D wdColorAutomatic
>        End With
>        With .Borders(wdBorderTop)
>            .LineStyle =3D wdLineStyleSingle
>            .LineWidth =3D wdLineWidth050pt
>            .Color =3D wdColorAutomatic
>        End With
>        With .Borders(wdBorderBottom)
>            .LineStyle =3D wdLineStyleSingle
>            .LineWidth =3D wdLineWidth050pt
>            .Color =3D wdColorAutomatic
>        End With
>        .Borders(wdBorderDiagonalDown).LineStyle =3D wdLineStyleNone
>        .Borders(wdBorderDiagonalUp).LineStyle =3D wdLineStyleNone
>        .Borders.Shadow =3D False
>    End With
>    With Options
>        .DefaultBorderLineStyle =3D wdLineStyleSingle
>        .DefaultBorderLineWidth =3D wdLineWidth050pt
>        .DefaultBorderColor =3D wdColorAutomatic
>    End With
> End Sub
>
> LOTS of that code reflects settings in the dialog box with which we're
> not concerned. By inspection, all we really need is:
>
> With Selection.Cells
>    With .Shading
>        .Texture =3D wdTextureNone
>        .ForegroundPatternColor =3D wdColorAutomatic
>        .BackgroundPatternColor =3D wdColorGold
>    End With
> End With
>
> Which can be condensed into:
> =20
> With Selection.Cells.Shading
>    .Texture =3D wdTextureNone
>    .ForegroundPatternColor =3D wdColorAutomatic
>    .BackgroundPatternColor =3D wdColorGold
> End With
>
> If you put the insertion point in any table cell, then run that code, it
> shades the cell "gold."   =20
>
> If you combine this with the code provided by Anthony, you should be
> able to get all you want out of that macro button.
>
> You can record a macro to find out the "VBA name" of the colors you
> want. You can see a complete list of them by opening the object browser
> window in the VBE and searching for "wdColor." Of course, that won't
> show you what they look like.
>
> Bear
>
> *************************************************************
> You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
> MicrosoftOffice@xxxxxxxxxxxxxxxx
>
> To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
>
> To Unsubscribe from this group, visit the group's homepage and use the
> dropdown menu at the top.  This will allow you to unsubscribe your email
> address or change your email settings to digest or vacation (no mail).
> //www.freelists.org/webpage/mso
>
> To be able to share files with the group, you must join our Yahoo sister
> group.  This group will not allow for posting of emails, but will allow you
> to join and share problem files, templates, etc.:
> http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for
> FILE SHARING ONLY.
>
> If you are using Outlook and you see a lot of unnecessary code in your
> email messages, read these instructions that explain why and how to fix it:
> http://personal-computer-tutor.com/abc3/v28/greg28.htm
> *************************************************************
>


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top.  This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to share files with the group, you must join our Yahoo sister group. 
 This group will not allow for posting of emails, but will allow you to join 
and share problem files, templates, etc.:  
http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for FILE 
SHARING ONLY.

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************

Other related posts: