Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Event on time Pin
michaelgr125-May-09 20:01
michaelgr125-May-09 20:01 
GeneralRe: Event on time Pin
michaelgr125-May-09 20:39
michaelgr125-May-09 20:39 
GeneralRe: Event on time Pin
S. Senthil Kumar25-May-09 21:25
S. Senthil Kumar25-May-09 21:25 
QuestionHow to download folder from Web Server Pin
himuskanhere25-May-09 19:13
himuskanhere25-May-09 19:13 
AnswerRe: How to download folder from Web Server Pin
N a v a n e e t h25-May-09 19:54
N a v a n e e t h25-May-09 19:54 
GeneralRe: How to download folder from Web Server Pin
himuskanhere25-May-09 20:10
himuskanhere25-May-09 20:10 
QuestionInsert HTML Formatted Text On Word Document Using C# [modified] Pin
Niks775525-May-09 18:34
Niks775525-May-09 18:34 
AnswerRe: Insert HTML Formatted Text On Word Document Using C# Pin
TALHAKOSEN9-Jun-09 1:54
TALHAKOSEN9-Jun-09 1:54 
it is late answer i know ))

Create a word doc, and insert a bookmark into that, then you can paste your string to that bookmarked place wit trhe code below

private void button2_Click(object sender, EventArgs e)
{
WordApp = new Word.ApplicationClass();

fileName = @"yourworddocname";
Microsoft.Office.Interop.Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref Format, ref realencode, ref isVisible, ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;
WordApp.Visible = true;

bookmarkdene(aDoc, "yourbookmarinworddoc", yaz);
}

private static string HtmlClipboardData(string html)
{
StringBuilder sb = new StringBuilder();
Encoding encoding = Encoding.GetEncoding("utf-8");
string Header = @"
Version: 1.0
StartHTML: {0:000000}
EndHTML: {1:000000}
StartFragment: {2:000000}
EndFragment: {3:000000}
";
string HtmlPrefix = @"
!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//TR""
html
head
meta http-equiv=Content-Type content=""text/html; charset={0}""
head
body
!--StartFragment--
";
HtmlPrefix = string.Format(HtmlPrefix, encoding.WebName);

string HtmlSuffix = @"
<!--EndFragment-->
</body>
</html>
";

// Get lengths of chunks
int HeaderLength = encoding.GetByteCount(Header);
HeaderLength -= 16; // extra formatting characters {0:000000}
int PrefixLength = encoding.GetByteCount(HtmlPrefix);
int HtmlLength = encoding.GetByteCount(html);
int SuffixLength = encoding.GetByteCount(HtmlSuffix);

// Determine locations of chunks
int StartHtml = HeaderLength;
int StartFragment = StartHtml + PrefixLength;
int EndFragment = StartFragment + HtmlLength;
int EndHtml = EndFragment + SuffixLength;

// Build the data
sb.AppendFormat(Header, StartHtml, EndHtml, StartFragment, EndFragment);
sb.Append(HtmlPrefix);
sb.Append(html);
sb.Append(HtmlSuffix);
MessageBox.Show(sb.ToString());
//Console.WriteLine(sb.ToString());
return sb.ToString();
}

public void bookmarkdene(Word.Document aDoc, string bookmarkName, string yourhtmlstring)
{
try
{
object bookmark = bookmarkAdi;
object missing = System.Reflection.Missing.Value;
object pasteType = Word.WdPasteDataType.wdPasteHTML;

DataObject clipDO = new DataObject();

if (aDoc.Bookmarks.Exists(bookmark.ToString()))
{
Word.Range rangeTbl = aDoc.Bookmarks.get_Item(ref bookmark).Range;

clipDO.SetData(DataFormats.Html,HtmlClipboardData(yourhtmlstring));
Clipboard.SetDataObject(clipDO, true);

rangeTbl.PasteSpecial(ref missing, ref missing, ref missing, ref missing, ref pasteType, ref missing, ref missing);
}
else
{

}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}

thanks for everything i have...

QuestionHelp me about OCR Pin
Phoiphapham25-May-09 16:46
Phoiphapham25-May-09 16:46 
AnswerRe: Help me about OCR Pin
Mycroft Holmes25-May-09 17:52
professionalMycroft Holmes25-May-09 17:52 
AnswerRe: Help me about OCR Pin
Dave Kreskowiak25-May-09 18:01
mveDave Kreskowiak25-May-09 18:01 
QuestionRe: Help me about OCR Pin
Phoiphapham27-May-09 18:26
Phoiphapham27-May-09 18:26 
AnswerRe: Help me about OCR Pin
Dave Kreskowiak28-May-09 2:03
mveDave Kreskowiak28-May-09 2:03 
AnswerRe: Help me about OCR Pin
Christian Graus25-May-09 18:29
protectorChristian Graus25-May-09 18:29 
GeneralRe: Help me about OCR Pin
Phoiphapham27-May-09 18:29
Phoiphapham27-May-09 18:29 
QuestionCut, Copy Paste TreeNodes Pin
Rafone25-May-09 14:35
Rafone25-May-09 14:35 
AnswerRe: Cut, Copy Paste TreeNodes Pin
Mycroft Holmes25-May-09 15:57
professionalMycroft Holmes25-May-09 15:57 
GeneralRe: Cut, Copy Paste TreeNodes Pin
Rafone26-May-09 2:47
Rafone26-May-09 2:47 
Questionanybody knows Tools for veiw problems with final code Pin
DVD_RR25-May-09 13:29
DVD_RR25-May-09 13:29 
QuestionSubscribe to event on all instances in array Pin
DaveyM6925-May-09 12:58
professionalDaveyM6925-May-09 12:58 
AnswerRe: Subscribe to event on all instances in array Pin
N a v a n e e t h25-May-09 17:29
N a v a n e e t h25-May-09 17:29 
GeneralRe: Subscribe to event on all instances in array Pin
DaveyM6925-May-09 23:03
professionalDaveyM6925-May-09 23:03 
QuestionTo stop keys Pin
ammoti25-May-09 11:51
ammoti25-May-09 11:51 
AnswerRe: To stop keys Pin
_Maxxx_25-May-09 12:12
professional_Maxxx_25-May-09 12:12 
AnswerRe: To stop keys Pin
EliottA25-May-09 12:14
EliottA25-May-09 12:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.