Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET
Hi,
 
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
        wordapp.Selection.TypeText(TextBox1.Text)
 
        '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
hasbina1.2K
Edited 28-Sep-12 8:48am
RaisKazi33.2K
v5
Comments
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
   
Marcus,
 
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.
 
—SA
hasbina at 29-Sep-12 7:29am
   
got it...

1 solution

Rate this: bad
good
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 vb.net[^].
 
—SA
  Permalink  
Comments
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...
—SA
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.
—SA

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

  Print Answers RSS
0 OriginalGriff 7,205
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,474


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 3 Aug 2013
Copyright © CodeProject, 1999-2014
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