Results 1 to 4 of 4
  1. #1
    Amras is offline Novice
    Windows 2K Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Sioux Falls, SD
    Posts
    29

    appWord.Selection.Paste is throwing runtime error 4198 "Command failed"

    Good afternoon, all. Thanks for taking a moment to review my issue.

    I've got a little bit of code that I located online that captures the active screen so the Supervisors have a "scorecard" they can use in discussions with the reps. Once my application completes that sub, it creates a Word document and pastes the screen capture and saves it to the Supervisor's Documents folder. The code works flawlessly for me in testing, but whenever any of the Supervisors use it, Access throws a code at line 1027:

    Code:
    1021        FilePath = "C:\users\" & Environ("USERNAME") & "\Documents\"
    1022        FileName = cboEmployeeName & " " & cboMonth & " " & cboYear & " Scorecard.docx"
    1023        'ScreenCapture  'this code captured all monitors
    1024        PrintScreen 'this code captures just the active monitor
    1025        Set appWord = CreateObject("Word.Application")
    1026        appWord.Documents.Add
    1027        appWord.Selection.Paste
    1028        appWord.ActiveDocument.SaveAs FileName:=FilePath & FileName, FileFormat:=wdFormatDocument
    1029        appWord.Quit
    I hope I've presented my problem sufficiently. Any help would be appreciated.

    Make it a great day!

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Have you tried to suppress Warnings? are your trust center settings set to allow function? Are your supervisors rights the same as yours on the PC?

    Per this post
    https://social.msdn.microsoft.com/Fo...?forum=worddev

    Have you tried inserting a pause when this error occurs as per the thread above? This could be a racing condition.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Why are you doing screen capture, exactly what is being captured - an open form of the db? Why do you need to save data into another format? Why not just open form to the same record when data needs to be viewed?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Amras is offline Novice
    Windows 2K Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Sioux Falls, SD
    Posts
    29
    Thanks for taking a moment of your time to review this, Perceptus and June7. To answer June7's question, what's being captured is essentially a "screen-shot" of the completed form. One of the Supervisors had asked for this to be able to use it as a coaching opportunity with their reps during interim reviews. One screen-shot for each rep's record. The Supervisor likes the form and felt that it captured all of the information he wanted to share in his reviews. To answer Perceptus' question, I don't believe that suppressing Warnings will help, as this isn't an issue of a Warning being generated. The command "appWord.Selection.Paste" fails. I haven't yet tried anything from the thread you referenced as I was pulled to other projects after making my initial request on this forum. I'm going to look at this again on Monday. Have a great weekend, all!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-02-2015, 02:06 PM
  2. Replies: 4
    Last Post: 12-12-2014, 08:48 AM
  3. "Run Time Error 3146, ODBC call failed" :(
    By selvakumar.arc in forum Access
    Replies: 0
    Last Post: 12-04-2014, 01:57 PM
  4. Replies: 0
    Last Post: 03-11-2012, 09:19 AM
  5. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums