[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Opening word, inserting some text and a graph from VB

Ok, someone posted some very useful code for exporting data into an excel spreadsheet from VB. I'd like to do the same thing with Word. I would like to open up word, put some text into a new document,and (if possible) insert a graph from a second party vb graph. If the graph part doesn't work, then is there a way to generate a chart in Word from VB?
Thanks!

Jeff
0
jscharpf
Asked:
jscharpf
  • 7
1 Solution
 
jscharpfAuthor Commented:
Oh i forgot.
Here is what I have so far and this does not open Word up..

Global NewDoc As Word.Application

Set NewDoc = New Word.Application

NewDoc.Documents.Add

With NewDoc
    With .ActiveDocument


I'm using VB6.0 and word 97 is installed

Thanks

Jeff
0
 
jscharpfAuthor Commented:
Nuther oops..

I DID get word to open with .visible =True

So once it's open,  uh.. now what lol?

Jeff
0
 
samopalCommented:
First of all, put

NewDoc.Visible = True

In Word :
Menu > Tools > Macro > Record New Macro
and create your document manually.
After that stop macro recording, open it and copy into your VB programm....

Enjoy!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
RuchiCommented:
To your second comment,

You need to add a reference to the MS Word 8.0 Object Library...

Dim oAppl As Word.Application
Dim oWord As Word.Document

Dim sFile As String

Set oAppl = New Word.Application
'Set oWord = oAppl.Documents.Open("c:\Test.doc")
Set oWord = oAppl.Documents.Open(sFile)
.......
.......
code..
.......
.......

Set oWord = Nothing
Set oAppl = Nothing
End Sub
0
 
jscharpfAuthor Commented:
Nuther oops..

I DID get word to open with .visible =True

So once it's open,  uh.. now what lol?

Jeff
0
 
jscharpfAuthor Commented:
Ok, I guess I wasn't very clear.
I'm able to open word and a new document.
Now I've got some variables and strings that I wish to place into the document, along with a graph.
Can this be done?
0
 
jscharpfAuthor Commented:
Ok, I've been able to insert a graph by using the third partys functions where they allow me to export there object as a metafile to the clipboard. Then in the word programming I do a .paste and it puts the graph into my document. Now, how do I insert tables, text, and move around the document?

Jeff
0
 
jscharpfAuthor Commented:
Ok, I've been able to insert a graph by using the third partys functions where they allow me to export there object as a metafile to the clipboard. Then in the word programming I do a .paste and it puts the graph into my document. Now, how do I insert tables, text, and move around the document?

Jeff
0
 
jscharpfAuthor Commented:
Thanks for the help.
Sorry about the delay
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now