Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change Font For Word Document? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have the following code that populates lblMessage.Caption

    <pre>lblMessage.Caption = "This Access database called " _
    & GetPref("Application Title") _
    & vbCrLf & vbCrLf & _
    CurrentDb.Name _
    & vbCrLf & vbCrLf & _
    " is CLOSING NOW for " & _
    "Automatic Administration. " _
    & vbCrLf & vbCrLf & _
    "The time is " & Now() _
    & vbCrLf & vbCrLf & _
    "Please remember to exit out of the " _
    & GetPref("Application Title") & _
    " before you leave the office!"
    </pre>


    I then open a Word document and display strToDisplay (lblMessage.Caption)

    <pre>With objWord
    .Visible = True
    .Documents.Add
    .Selection.Text = strToDisplay
    nd With
    </pre>


    For the last line:

    Please remember to exit out of the Building Permit System before you leave the office!

    Is there any way to increase to default font size from Normal Times New Roman 12 to 18? How red font also?

    Thanks, John

    Current Results in Word document:

    This Access database called Building Permit System

    F:AppsAccess2kBuild.mdb

    is CLOSING NOW for Automatic Administration.

    The time is 11/28/2006 9:09:46 AM

    Please remember to exit out of the Building Permit System before you leave the office!

  2. #2
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Font For Word Document? (a2k (9.0.6926)

    Wouldn't it be simpler to incorporate the text you want into the Word object directly or at least as two different strings for the two different formatting requirements. Something like the following will create the text in the attached word doc. Easy enough to run the word object from Access the way you already are. Add in your line breaks and getprefs stuff the way you already are.

    Selection.TypeText Text:="This is a "
    Selection.Font.Name = "Arial Black"
    Selection.Font.Size = 18
    Selection.TypeText Text:="big test."
    Selection.TypeParagraph
    Selection.Style = ActiveDocument.Styles("Normal")
    Selection.TypeText Text:="And still is."

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Font For Word Document? (a2k (9.0.6926)

    Yes it would, thanks for the tip

    Can you point me to other Word Object/Selection. options in Help? my a2k Help is awful need specific search criteria

    Thanks, John

  4. #4
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change Font For Word Document? (a2k (9.0.6926)

    I've found the simplest way to figure out what to do in code with the Word object is to open word, and record a macro doing what I want. (In fact, that is what I did for you <img src=/S/clever.gif border=0 alt=clever width=15 height=15> .) Then you can open the macro in the VBA editor in word and find your syntax that way.

    You should be able to put your cursor on any item in the word VBA editor and hit F1 to get more info from Word Visual Basic help directly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •