Click here to Skip to main content
10,500,000 members (63,226 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: .NET

I would like to populate a word document using a windows form (i.e. have a user enter text into a textbox in windows form (i.e. textbox1) and then click submit and have the application open a word document that I have created and place the users text into a form field using a bookmark (i.e. bookmark1).

got below code

Imports Microsoft.Office.Interop
Public Class Form1
    Dim wordapp As Word.ApplicationClass
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'open word document
        wordapp = New Word.Application
        Dim objdoc As Word.Document = wordapp.Documents.Open("c:\test")
        'go to bookmark
        wordapp.Selection.GoTo(What:=Word.WdGoToItem.wdGoToBookmark, Name:="Bookmark_Name")
        ' enter text from textbox
        'make document visible
        wordapp.Visible = True
    End Sub
End Class

I am using c#. I want to write code in c#.

Please help.
Posted 27-Sep-12 23:39pm
Edited 28-Sep-12 8:48am
Richard MacCutchan at 28-Sep-12 9:38am
And your question is?
ryanb31 at 28-Sep-12 14:27pm
What is the question? Also, record a macro doing what you want and that will give you a good starting point.
Marcus Kramer at 28-Sep-12 15:50pm
if you want the code in C#, go ahead and translate the VB code you have. That seems like a pretty simple thing.
Sergey Alexandrovich Kryukov at 3-Aug-13 22:54pm

You helped me to understand what this question is about, thank you.
If this is just about code translation, I suggested some good ways to translate automatically, some on-line and a really comprehensive off-line solution. Please see my answer.

hasbina at 29-Sep-12 7:29am
got it...

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

In my past answers, I suggested some really good ways to translate from VB.BET to C# and visa versa automatically. There are both on-like solution and a really comprehensive off-line solution:
COde Line Interpretatio of C# to VB.NET[^],
Need to convert vb code to c#[^],
FixedPage to ContentPage convert c# code into[^].

Ron Beyer at 3-Aug-13 23:00pm
How did you find this? Its almost a year old...
Sergey Alexandrovich Kryukov at 3-Aug-13 23:09pm
What difference does it make? A problem is a problem, it is actual and still not resolved.
Sometimes I see such posts that makes me asking: "what else this person posted, I wonder?"... :-) I was looking at some fresh post, and then...
Ron Beyer at 3-Aug-13 23:11pm
No difference at all, just curious how you came across it, I usually only go back a page or two but this must have been pretty deep :)
Sergey Alexandrovich Kryukov at 3-Aug-13 23:16pm
I answered. It's not deep if you go back not by the list of all questions, but by the list of some member's posts.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 180
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,484
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 3 Aug 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100