Urgent, Please replay everyone! I have used Suan Wong work from c# corner for my c# desktop application with Access database. It works fine when I run on visual studio but after changed to .exe file it puts 0 on Ms word templete to for the report.
What shall I do?
Rajkiran SwainPosted Mar 30, 2023, 6:34 AM
It's difficult to pinpoint the exact issue without seeing your code, but here are a few things you can check:
Make sure the file paths for your Word template are correct in your code. When running the .exe file, the path to the template may be different from when you run it in Visual Studio. You can try using absolute paths instead of relative paths to ensure that the file is found correctly.
Check if any files or resources that your application relies on are missing when running the .exe file. This can happen if they were not included in the build process. You can try adding the template file to your project and setting its build action to "Content" so that it gets included in the build.
Verify that your .exe file has the required permissions to access and modify the Word template file. If the file is read-only or inaccessible, your application may not be able to write to it.
Try adding some debug output to your code to see if you can narrow down where the issue is occurring. You can use Console.WriteLine or Debug.WriteLine to output the values of variables or messages at various points in your code to help you determine where things are going wrong.
If none of these steps solve the issue, you may need to provide more information or seek assistance from someone with more experience troubleshooting C# and Word integration.
NURU DAWUDPosted Mar 30, 2023, 9:53 AM
I have used the above source code. It is fine on visual studio but after changed to .exe file the word templete couldn't change the content. I think the path is on the StartupPath so it makes it by default Read Only file.
installation path = C:\Program Files (x86)\Ocean Ict Center\Setup
path on source code =
string samplePath = Application.StartupPath + Path.DirectorySeparatorChar + "Template.docx";
string docxPath = Application.StartupPath + Path.DirectorySeparatorChar + "Result.docx";
How it can be solved?
You can also show me how to use Report Viewer with Ms Access database with the source code above.
For more the source file and the description found on c-sharpcorner.com with the following link copy and paste on you browser:
https://www.c-sharpcorner.com/UploadFile/38268a/create-word-document-from-win-form-with-users-data/