Is there any way to hide the text contents in word doc?

Posted by Gudevg under C# on 4/30/2012 | Points: 10 | Views : 1312 | Status : [Member] | Replies : 8
Hi folks,

How could we hide the text contents present in a word document? Any idea please share it?

Regards,
Deepak G.

Deepakkumar G.


Responses

Posted by: Sakthi.Singaravel on: 4/30/2012 [Member] Silver | Points: 25

Up
0
Down
Hi,

Refer this link for hide the text contents present in a word document..

http://www.online-tech-tips.com/ms-office-tips/word-hidden-text/

Regards,
Singaravel M

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gudevg on: 4/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Singaravel M.
I am asking about the possibilities in (C#)Programmatically not manually?

Deepakkumar G.

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/30/2012 [Member] Silver | Points: 25

Up
0
Down
For get current opening doc..

Dim mWord As Word.Application = Nothing

mWord = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application")


For hide selected text..

mWord.Selection.Font.Hidden = True


Regards,
Singaravel M

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gudevg on: 4/30/2012 [Member] Starter | Points: 25

Up
0
Down
Timely Response. Thanks Singaravel M.

I will check it now

Deepakkumar G.

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/30/2012 [Member] Silver | Points: 25

Up
0
Down
okay..

Regards,
Singaravel M

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gudevg on: 4/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hai Singaravel,

I use that hide code in my project with correct namespace but it shows the following error
Word.Selection.Font.Hidden == true


Error:
1) Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
2) An object reference is required for the non-static field, method, or property 'Word.Selection.Font.get'.

Will u please look into this?


Thanks in advance.

Deepakkumar G.

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gudevg on: 4/30/2012 [Member] Starter | Points: 25

Up
0
Down
This is my Code for creating duplicate file

{

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void File_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
this.textBox1.Text = this.openFileDialog1.FileName;
}

private void Submit_Click(object sender, EventArgs e)
{


//static void Main(string[] args)
{
// Initialize a bogus parameter for arguments we don't care about
object oMissing = System.Reflection.Missing.Value;

// Set the paths for the old and new documents (edit as needed)
object oldDocPath = (object)@"c:\Word.doc";
object newDocPath = (object)@"c:\New Word.doc";

// Get a Word application
Word.Application app = new Word.Application();

// Open the existing document
Word.Document oldDoc = app.Documents.Open(ref oldDocPath,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

// For hide selected text
Word.Selection.Font.Hidden == true;

// SaveAs
app.ActiveDocument.SaveAs(ref newDocPath,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);


// Close the document and quit the application
oldDoc.Close(ref oMissing, ref oMissing, ref oMissing);
app.Quit(ref oMissing, ref oMissing, ref oMissing);

}
}
}
}




Deepakkumar G.

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/30/2012 [Member] Silver | Points: 25

Up
0
Down
// For hide selected text
               oldDoc.Selection.Font.Hidden == true;


Regards,
Singaravel M

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response