Word Automation Problem When Using NAS
seff_yohanson
Member Posts: 23
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:
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
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
0
Comments
-
Does the NAS write any errors to the windows event log?
You can also try to debug the nas to see where it stops.0 -
WrdApp.Visible := TRUE;
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.0 -
Thanks guys for your help. I have tried the windows logs and nothing

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.0 -
Try shorten your variable to just one letter.
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.Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
I did see this, and thought I might have problems. Just wanted to see if anyone had similar issues.
Odd how the variable below just wont compile, which must be a fairly basic thing?
WrdApp Automation 'Microsoft Word 14.0 Object Library'.Application0 -
had the same problem, when "excel 14 automation" var was defined globally. Works ok if defined locally, and passed to functions as reference.0
-
Hi
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
Thomas0 -
Thanks guys!
This helped the object compile. Still no luck running automation using a NAS. Upgraded a test DB to 2009 r2 and the same happens. I am going to try earlier versions of Word to get earlier versions of the automation objects see if I have any more luck.
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.. :-k0 -
Can you try to run the codeunit as the nas user (windows user) and on the same machine where nas runs?0
-
Runs fine under the same windows (domain) user that is set up to run the NAS.0
-
Running on the nas machine?0
-
Yes - in our test environment the DB, NAS and client are all running from the same machine...and I am logged on as the user running the NAS.0
-
In the live environment that we are building there we have now had some success
by installing word 2003 (which worked straight off) then upgrading to word 2010 (it still worked), which is very bizzare!!!
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!0 -
seff_yohanson wrote:In the live environment that we are building there we have now had some success
by installing word 2003 (which worked straight off) then upgrading to word 2010 (it still worked), which is very bizzare!!!
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?0 -
Yes, manually running the codeunit = fine, NAS running = winword.exe left open in the task manager for every time the NAS runs the codeunit. Eventually it woud run out of memory with multiple winwords open. we have just found the same happens for excel.0
-
As i understand functionality itself works, but winword process left alive at end of your code execution? If so - you can just kill process using Taskkill /IM winword.exe /F at end of your code.0
-
Hi, just wanted to say thanks to everyone for their help. I found the solution in another article on Mibuso (wish I had found this a couple of weeks ago :roll:
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 again0 -
Are you running NAS under domain user or under "network service" user?0
-
Under a domain user, with full administrator permissions0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

