From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when the Application try to write into a doc file

Hello everyone!

 

I have a problem. I build an application who save, when i press a button, a doc file with some data. I use for that "NI-Report generation..save report to file".  When i press  the button for the first time the app create the file in directory (C:/program files/myapp/data) but then, when i press the button again the app  give me an error : "Exception occured in Microsoft Word: the file is read - only."

 

But if i close the program and start the program again and then press the button , this error NOT occur; but if i press the button again the error will occur.

 

Thank you for your time!

Marius

0 Kudos
Message 1 of 21
(3,473 Views)

Hello Marius,

 

without seeing your code it is hard to say what is going on.

Just a guess: Did you call 'Dispose Report.vi'?

 

UliB

0 Kudos
Message 2 of 21
(3,467 Views)

Hi Ulib!

I attash the file with the code .That error occur after install app. Before , in the labview project, this error is not occur.

Thank you!

0 Kudos
Message 3 of 21
(3,455 Views)

Hi Marius,

                 The Problem with the code is that for the first time when you click you will get the document and it will be in open state. So next time when you click the vi cannot update the document so you are getting this error. just follow the steps

1) In the Dispose Report function wire the Close Report?T Terminal to True. this will solve the issue .

 

I have also attached the vi snippet for your reference.

 

Kudos are Welcome 😄

 

Certified-LabVIEW-Associate-Dev_rgb (1).jpg

 

Certified LabVIEW Developer
Best LabVIEW Programmer @NIDAYS 2015
0 Kudos
Message 4 of 21
(3,439 Views)

 Hi Joel!

I do that as you say but isn't work. by default this wire is True, no?

Thank you.

0 Kudos
Message 5 of 21
(3,420 Views)

Hi Marius,

                  Can you tell me whether you want to overwrite the existing file or you want to replace???

 

Certified-LabVIEW-Associate-Dev_rgb (1).jpg

Certified LabVIEW Developer
Best LabVIEW Programmer @NIDAYS 2015
0 Kudos
Message 6 of 21
(3,402 Views)

Hy Joel!

I want to replace this file! 

Thank you

0 Kudos
Message 7 of 21
(3,392 Views)

Hi Marius,

                 Make this small change in your code and it will work. add a delete function so that you wont get the error again

 

 

Hope this works 🙂

               report.png

 

 

Certified-LabVIEW-Associate-Dev_rgb (1).jpg

Certified LabVIEW Developer
Best LabVIEW Programmer @NIDAYS 2015
0 Kudos
Message 8 of 21
(3,376 Views)

@marius.lucian wrote:

Hello everyone!

 

I have a problem. I build an application who save, when i press a button, a doc file with some data. I use for that "NI-Report generation..save report to file".  When i press  the button for the first time the app create the file in directory (C:/program files/myapp/data) but then, when i press the button again the app  give me an error : "Exception occured in Microsoft Word: the file is read - only."

 

But if i close the program and start the program again and then press the button , this error NOT occur; but if i press the button again the error will occur.

 

Thank you for your time!

Marius


The issue might be Windows permissions because you are editing a file located in C:\Program Files. The first time it work because you are creating the file not editing it.  Right-click on your data folder and check the security properties to see if the user has the modify rights.

 

 

edit: Even if it is not the cause I would recommend you save your data file somewhere else.

 

Ben64

0 Kudos
Message 9 of 21
(3,361 Views)

Hy Joel: I tried it but did not work.:(

Hello Ben

I open app in run as administrator, the first time create a file and after the file have permissions:

All application packages : read& execute and Read are checked.

System : there are all of them checked: full control, modify,read&execute,read,write,special permissions

Administrators: idem SYSTEM

Users : Idem All application packages.

 

There are all permissions for that file.

I tried to find a method to set permissions to the file, but it didn't work.(set permissions function).

 

If i start the app in Administrator mode, i should have the administrator permissions, so...?

 

 

Thank you.

 

0 Kudos
Message 10 of 21
(3,347 Views)