Hi guys,
I have a problem running word automation tasks in a codeunit using a NAS that I have been trying to figure out for hours.
The original code saved a word file as a PDF. When running the codeunit manually from the object designer it saved a PDF fine, but the same codeunit run by the NAS doesnt do anything and left a copy of WinWord.exe open as a process in the task manager.
I then simplified the code as much as I can so I can try and figure out what is happening but I still have the same issue. My (simplified) code have in a codeunit is as follows:
docPath := 'c:\...\name.doc';
IF ISCLEAR(WrdApp) THEN
IF NOT CREATE(WrdApp, TRUE) THEN
ERROR('error! failed to create word app');
WrdApp.Visible := TRUE;
WrdApp.Documents.Open(docpath);
Again when running manually the document opens. When run using a NAS (using the same windows logon) nothing happens, and winword is left running in the background. Im using NAV 5.1 UP2, word 2003 (tried 2010 too!)
Thanks for any help,
Marc
Comments
You can also try to debug the nas to see where it stops.
could be an answer. NAS do not support user interaction, and no visible controls can be invoked. But, I also heard somewhere that word automation cannot be run on nas at all, but newer tried.
I also tried debugging it before and this works fine! It has previously been running fine under a NAS on windows server 2003 but we are in the progress of moving to a new server (2008 r2 64-bit) hence trying to get it to work
I may have spotted some the problem - the automation variables have lost their 'subtype' - simply saying "Unknown Automation Server.Application".
I have now corrected this, however, one variable will not compile! I even created a test table, added the single variable below and get the error below. Help!
Name DataType Subtype Length
WrdApp Automation 'Microsoft Word 14.0 Object Library'.Application
The variable WRDAPP::MAILMERGEDATASOURCEVAL is definaed more than once. An example could be: ;File' exists as both a data typr and a global variable.
And read the info in this link: http://support.microsoft.com/default.as ... -us;257757
This tells us: So if it works, you are lucky. If it doesn't, you are on your own.
Odd how the variable below just wont compile, which must be a fairly basic thing?
WrdApp Automation 'Microsoft Word 14.0 Object Library'.Application
Just my two cents:
I think this has been discussed in another thread, but if its not possible to declare the automation as a local, you also can export the object as text and delete the whole section with the events and then import it back. Nav COM interface distinguishes on first (or so) characters of functions only, so it happens that some functions appear more than once.
Regards
Thomas
If this is not recommended can anyone suggest an alternative? Reading the article again it refers to using "Open XML file" code using .NET - is this the only option? Seems a very complicated implementation.. :-k
So I thought we had found the the solution. But tried doing exactly the same on another identical live server (and our test server) and no automation using even using word 2003!
And still manually ok, but not with nas, isn't it?
viewtopic.php?t=51723
To simply and confirm the simplified situtation in case any one else has this isssue - I had a Codeunit with one function to open a word document from a fixed location and save as a PDF. When :
* Run from object designer it saved the file succesfully
* When using command prompt to start the NAS in degbug mode it worked
* When run by the NAS (function call in codeunit 1) it failed, with no error messages (including event log) to help debug. Windowrd.exe was left running in the task manager
As soon as the folders below were created it worked fine!!!
C:\Windows\SysWOW64\config\systemprofile\Desktop
C:\Windows\System32\config\systemprofile\Desktop
Thanks again