TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rals V
NA
3
0
Unable to unprotect word file using C#
Jul 24 2009 11:31 AM
//code Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); object nullobj = System.Reflection.Missing.Value; string pass = "abcd1234"; object password = pass; object FName = fileName; Microsoft.Office.Interop.Word.Document aDoc = null; wordApp.Visible = false; aDoc = wordApp.Documents.Open(ref FName, ref nullobj, ref nullobj, ref nullobj, ref password, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); aDoc.Activate(); if (aDoc.HasPassword) aDoc.Password = null; if (aDoc.ProtectionType != wdProtectionType.wdNoProtection) aDoc.Unprotect(ref password); aDoc.SaveAs(ref FName, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); aDoc.Close(ref nullobj, ref nullobj, ref nullobj); } //code Hi All, I use this above code to remove the password and unprotect my word document. But for some strange reason it works fine on some files but does not remove the password protection on some. Is there something I am missing? Thanks in advance. Rals Apologies for the wierd display
Reply
Answers (
3
)
access a form from other forms
Problem in datagridview datetimepicker column.