• 0

how to export


Question

i was wondering how can i create a new word document( office xp) using vb.net 2002 and export the data that is in a textbox to a bookmark!!! i've looked around but i can only find code for vb.net 2003 and office 2003

a little help would be appreciated

im

i've tried this

on top of the form

Imports Word = Microsoft.Office.Interop.Word( he doesn't recognize)

gives this--> Namespace or type 'Word' for the Imports 'Microsoft.Office.Interop.Word' cannot be found.

and associated to a button the following code

Dim export As word.Application--> Type 'word.Application' is not defined.

Dim newdoc As word.Document--> Type 'word.Document' is not defined.

Edited by paxa
Link to comment
https://www.neowin.net/forum/topic/315799-how-to-export/
Share on other sites

7 answers to this question

Recommended Posts

  • 0
  paxa said:
i was wondering how can i create a new word document( office xp) using vb.net 2002 and export the data that is in a textbox to a bookmark!!! i've looked around but i can only find code for vb.net 2003 and office 2003

a little help would be appreciated

im

i've tried this

on top of the form

Imports Word = Microsoft.Office.Interop.Word( he doesn't recognize)

gives this--> Namespace or type 'Word' for the Imports 'Microsoft.Office.Interop.Word' cannot be found.

and associated to a button the following code

Dim export As word.Application--> Type 'word.Application' is not defined.

Dim newdoc As word.Document--> Type 'word.Document' is not defined.

585863497[/snapback]

You need the Primary Interop Assembly for Office 2002(XP).

http://msdn.microsoft.com/vstudio/downloads/tools/

You need to reference the Word assembly in your project.

Link to comment
https://www.neowin.net/forum/topic/315799-how-to-export/#findComment-585863955
Share on other sites

  • 0

as i said before now i can open the document that i want, but the problem is that i can't export the contents of a text to a place in a document!! i' ve created the bookmarks but it doesn't export the contents

i've tried this

oDoc.Bookmark.item.range("teste").range.textTextBoxTextBoxremetente.Text

to export but i doesn't work, it opens the document but it doesn't do want i want

once again a little help would be appreciated

Link to comment
https://www.neowin.net/forum/topic/315799-how-to-export/#findComment-585878436
Share on other sites

  • 0

i used this code to try to export the data that i want to export

Dim oWord As Word.Application

Dim oDoc As Word.Document

Dim oRange As Word.Range

Dim selection As Word.Selection

Dim obook As Word.Bookmarks

oWord = CreateObject("Word.Application")

oWord.Visible = True

'oDoc = oWord.Documents.Add

oWord.Documents.Add("c:\tempus\teste2.dot

If oDoc.ActiveDocument.Bookmarks.Exists("teste") = True Then

oDoc.ActiveDocument.Bookmarks("teste").Select()

End If

oDoc.ActiveDocument.Bookmarks.Add(Name = "teste", oRange:=selection.Range)

oDoc.Bookmark.item.range("teste").range.textTextBoxTextBoxremetente.Text

click the button that the code is associated

the following error appears

An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll

Additional information: Object variable or With block variable not set.

any help would be appreciated

Link to comment
https://www.neowin.net/forum/topic/315799-how-to-export/#findComment-585878717
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.