Sign in to follow this  
Followers 0
Andy007

Requested action failed

2 posts in this topic

Hi All,

I am a little stuck - I have written a word merge autoit program for a friend of mine.

It use to run fine and then some Group Policies where applied to his machine.

Now he gets the following error:

The requested action with this object has failed.

Runs ok as administrator but not as a normal user.

The IT guys says, "if you can tell me which policy to change, then I will look into it"... (please imagine a gruff voice)

Great help he was. The IT guy said it took him 3 days to setup the group policies.

I know nothing of group policies but I would like to help my friend.

; -----------------------------------------------------------------------------
; Name:   mymerge
; Date:   16/05/2008 AP
; -----------------------------------------------------------------------------
#NoTrayIcon
#include <Word.au3>
#include <File.au3>
Opt("MustDeclareVars", 1)
Opt("ExpandEnvStrings", 1)
global $param1, $param2, $param3
global $wd, $dc, $mm, $rng, $ver
global $logfile = @DesktopDir & "\debug.log"
$param1 = "WordMerge"
$param2 = "C:\template.doc"
$param3 = "C:\data.csv"
_WordMerge()
 
func _WordMerge()
  local $template = ""
  local $data = ""
  local $short_name = ""
  $template = $param2
  _LogThis("Word template file: " & $template)
  if ($template = "") then
    _LogThis("No template file provided...")
    MsgBox(0, "Error", "Unable to proceed - missing word template file.")
    SetError(1)
    return
  endif
  if not FileExists($template) then
    MsgBox(0, "Error", "Template file does not exist. (" & $template & ")")
    SetError(1)
    return
  endif
  $data = $param3
  _LogThis("Data file: " & $data)
  if ($data = "") then
    _LogThis("No data file provided...")
    MsgBox(0, "Error", "Unable to proceed - missing word data file.")
    SetError(1)
    return
  endif
  if not FileExists($data) then
    MsgBox(0, "Error", "Data file does not exist. (" & $data & ")")
    SetError(1)
    return
  endif
  _LogThis(" - opening template file: " & $template)
  $wd = _WordCreate($template,0,0)  ; Start invisible.
  if @error then
    _LogThis(" - unable to open ms word...")
    MsgBox(0,"Error","Unable to start word...")
    SetError(1)
    _MyExit()
  endif
  $ver = $wd.version
  _LogThis(" - word version: " & $ver)
  ; $dc = _WordDocOpen ($wd, $template)
  $dc = _WordDocGetCollection ($wd, 0)
  $wd.DisplayAlerts = 0
  _WordPropertySet ($wd, "visible", False)
  ; Mailmerge bits.
  _LogThis(" - processing merge...")
  $mm = $dc.MailMerge
  $mm.OpenDataSource ('"' & $data & '"', 0, true, true, true, false, "", "", false)
  $mm.Destination = 0 ; New document.
  $mm.execute
  ; Close template.
  _WordDocClose($dc,0)
  Sleep(100)
  ; Reset document to new document, then save to new file.
  $dc = _WordDocGetCollection ($wd, 0)
  $wd.ActiveWindow.ActivePane.View.Zoom.Percentage = 100
  _WordPropertySet ($wd, "visible", True)
  $wd.DisplayAlerts = -1
  Sleep(300)
  WinActivate("Form")
  _LogThis("Exiting...")
  exit
endfunc   ;==> _WordMerge
 
func _LogThis($txt)
  local $sDateNow
  local $sTimeNow
  local $fh
  ; If Logging then...
    $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY
    $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC
    $txt = $sDateNow & " " & $sTimeNow & " : " & $txt
    $fh = FileOpen($logfile, 1)
    if $fh = -1 then
      SetError(1)
      return 0
    endif
    FileWriteLine($fh, $txt)
    FileClose($fh)
  return
endfunc   ;==> _LogThis

Sorry for my coding standards.

Word does get started and hidden, then the error appears.

Can anyone please help.


Regards,Andy (no, the other one)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You'll need to troubleshoot/error check this further and pinpoint exactly which object call is failing. There's no way anyone can help you without that information.

Edit:

If I had to take a wild guess, I'd say you don't have the proper file access to your data files in the root of your C:\ drive. Sometimes group policies can limit your access in drive roots. Try to move the data files to a location in your profile. You should have pretty much free reign there.

Edited by wraithdu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0