Results 1 to 10 of 10
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing Word (MSACCESS 2003)

    I am trying to close Word from Access. The ending code clears it from task manager, but goes out with a bump. My screen view of my form dissapears for a moment or jolts with a flicker??

    'Create an instance of MS Word
    Set WD = CreateObject(Class:="Word.Application")
    ' WD.Visible = True
    '
    ' 'Open the Document
    WD.Documents.Open Filename:=LWordDoc, ReadOnly:=True

    PROCEDURE CODES IN HERE

    WD.Documents.Close
    WD.Quit
    Set WD = Nothing

  2. #2
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing Word (MSACCESS 2003)

    Managed to fix it by removing WD.Documents.Close.
    However does anyone know how having found word/words in a word dument one can open it to view it with the found words highlighted or coloured? I saw some code a while back but cannot remember where I saw it. Thanks

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing Word (MSACCESS 2003)

    Managed to highlight the words background, but want to change the fonts forecolour. Any suggestions, thanks.

    If WD.Selection.Find.Found Then

    WD.Options.DefaultHighlightColorIndex = wdRed
    WD.Selection.Range.HighlightColorIndex = wdRed

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing Word (MSACCESS 2003)

    Isn't it sufficient if the text is selected?

    If not, you can try

    WD.Selection.Font.Color = wdColorRed

  5. #5
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing Word (MSACCESS 2003)

    Thankyou Hans, color perfect. One thing I cannot explain is the fact I open the word document in read only, but when its closed from the word application it's obviously been changed and it asks if I want to save changes. I do not want users to save it or copy it, is there a way round it. Might not as the open document is nothing to do with Access? Thought I would just ask the question, thanks

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing Word (MSACCESS 2003)

    Opening a document as read-only means that you cannot save it to itself, but you can still use Save As to another filename, and Word will still prompt you to save changes when you close it, as you have found.
    If you don't want that, don't modify the document!

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing Word (MSACCESS 2003)

    You can close the document without saving changes (if any):
    <code>
    WD.Documents.Close SaveChanges:=False
    </code>
    or
    <code>
    WD.ActiveDocument.Close SaveChanges:=False</code>

  8. #8
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing Word (MSACCESS 2003)

    Thanks. The problem is when the word application opens showing the document it opens over the screen, so the obvious move for the user is to close word with its close button, that triggers the message do you want to save. I went as far as saying yes, and it said it could not be saved as read only. It would be good to kill the application closing question on saving.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing Word (MSACCESS 2003)

    You can try

    WD.ActiveDocument.Saved = True

    You must do this after modifying the document (for example by changing the color of text).

  10. #10
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing Word (MSACCESS 2003)

    Your a magician, that fools it!! Very many thanks, regards

Posting Permissions

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