I need to open a word doc and insert cell values at the end of certain lines
from within excel. I can get the file open but how do I control where the
text goes in the word application?
Thanks
I need to open a word doc and insert cell values at the end of certain lines
from within excel. I can get the file open but how do I control where the
text goes in the word application?
Thanks
You'll have to set a library reference to the Word object library. Then,
when you set an object to your document, you can use the Word object model
references (line, paragraph, story, and so on) to manipulate the ranges and
text of a Word document from within Excel VBA.
Ed
"Shawn G." <[email protected]> wrote in message
news:[email protected]...
> I need to open a word doc and insert cell values at the end of certain
lines
> from within excel. I can get the file open but how do I control where the
> text goes in the word application?
>
> Thanks
>
you wouldn't happen to have an explanple would you?
"Ed" wrote:
> You'll have to set a library reference to the Word object library. Then,
> when you set an object to your document, you can use the Word object model
> references (line, paragraph, story, and so on) to manipulate the ranges and
> text of a Word document from within Excel VBA.
> Ed
>
> "Shawn G." <[email protected]> wrote in message
> news:[email protected]...
> > I need to open a word doc and insert cell values at the end of certain
> lines
> > from within excel. I can get the file open but how do I control where the
> > text goes in the word application?
> >
> > Thanks
> >
>
>
>
Shawn:
This code sets an object to the Word application, and then sets and object
to a single document. The object "WordDoc" is your Word document, which
can be manipulated using the Word object model. If you've set the library
reference to Word, then the Word objects, properties, and methods are
available in the VBA Editor (such as my "Dim rng As Word.Range". Also note
the ending code.
Ed
Dim Word As New Word.Application
Dim WordDoc As New Word.document
Dim rng As Word.Range
''' "doc" in the following line is a string variable
''' previously Dim'd and set to the desired
''' document's complete file path and name
Set WordDoc = Word.Documents.Open(doc)
Word.Visible = True
Set rng = WordDoc.Paragraphs.Last.Range
WordDoc.Close
Word.Quit
Set WordDoc = Nothing
Set Word = Nothing
"Shawn G." <[email protected]> wrote in message
news:[email protected]...
> you wouldn't happen to have an explanple would you?
>
> "Ed" wrote:
>
> > You'll have to set a library reference to the Word object library.
Then,
> > when you set an object to your document, you can use the Word object
model
> > references (line, paragraph, story, and so on) to manipulate the ranges
and
> > text of a Word document from within Excel VBA.
> > Ed
> >
> > "Shawn G." <[email protected]> wrote in message
> > news:[email protected]...
> > > I need to open a word doc and insert cell values at the end of certain
> > lines
> > > from within excel. I can get the file open but how do I control where
the
> > > text goes in the word application?
> > >
> > > Thanks
> > >
> >
> >
> >
Dim Word As New Word.Application gives User-defined type not defined???
I am using Office 2003 if that means anything.
"Ed" wrote:
> Shawn:
>
> This code sets an object to the Word application, and then sets and object
> to a single document. The object "WordDoc" is your Word document, which
> can be manipulated using the Word object model. If you've set the library
> reference to Word, then the Word objects, properties, and methods are
> available in the VBA Editor (such as my "Dim rng As Word.Range". Also note
> the ending code.
>
> Ed
>
> Dim Word As New Word.Application
> Dim WordDoc As New Word.document
> Dim rng As Word.Range
>
> ''' "doc" in the following line is a string variable
> ''' previously Dim'd and set to the desired
> ''' document's complete file path and name
> Set WordDoc = Word.Documents.Open(doc)
> Word.Visible = True
> Set rng = WordDoc.Paragraphs.Last.Range
>
> WordDoc.Close
> Word.Quit
> Set WordDoc = Nothing
> Set Word = Nothing
>
>
> "Shawn G." <[email protected]> wrote in message
> news:[email protected]...
> > you wouldn't happen to have an explanple would you?
> >
> > "Ed" wrote:
> >
> > > You'll have to set a library reference to the Word object library.
> Then,
> > > when you set an object to your document, you can use the Word object
> model
> > > references (line, paragraph, story, and so on) to manipulate the ranges
> and
> > > text of a Word document from within Excel VBA.
> > > Ed
> > >
> > > "Shawn G." <[email protected]> wrote in message
> > > news:[email protected]...
> > > > I need to open a word doc and insert cell values at the end of certain
> > > lines
> > > > from within excel. I can get the file open but how do I control where
> the
> > > > text goes in the word application?
> > > >
> > > > Thanks
> > > >
> > >
> > >
> > >
>
>
>
You need to have the MS Word application installed to use the MS Word
functions. Assuming you're using Visual Basic 6.0, Select Project /
References ... and click the box labeled "Microsoft Word 9.0 Object Library",
and then click the "OK" button. After this, the calls to Work programming
classes should work.
--
In theory, there is no difference between theory and practice; in practice,
there is.
"Shawn G." wrote:
> Dim Word As New Word.Application gives User-defined type not defined???
> I am using Office 2003 if that means anything.
>
>
> "Ed" wrote:
>
> > Shawn:
> >
> > This code sets an object to the Word application, and then sets and object
> > to a single document. The object "WordDoc" is your Word document, which
> > can be manipulated using the Word object model. If you've set the library
> > reference to Word, then the Word objects, properties, and methods are
> > available in the VBA Editor (such as my "Dim rng As Word.Range". Also note
> > the ending code.
> >
> > Ed
> >
> > Dim Word As New Word.Application
> > Dim WordDoc As New Word.document
> > Dim rng As Word.Range
> >
> > ''' "doc" in the following line is a string variable
> > ''' previously Dim'd and set to the desired
> > ''' document's complete file path and name
> > Set WordDoc = Word.Documents.Open(doc)
> > Word.Visible = True
> > Set rng = WordDoc.Paragraphs.Last.Range
> >
> > WordDoc.Close
> > Word.Quit
> > Set WordDoc = Nothing
> > Set Word = Nothing
> >
> >
> > "Shawn G." <[email protected]> wrote in message
> > news:[email protected]...
> > > you wouldn't happen to have an explanple would you?
> > >
> > > "Ed" wrote:
> > >
> > > > You'll have to set a library reference to the Word object library.
> > Then,
> > > > when you set an object to your document, you can use the Word object
> > model
> > > > references (line, paragraph, story, and so on) to manipulate the ranges
> > and
> > > > text of a Word document from within Excel VBA.
> > > > Ed
> > > >
> > > > "Shawn G." <[email protected]> wrote in message
> > > > news:[email protected]...
> > > > > I need to open a word doc and insert cell values at the end of certain
> > > > lines
> > > > > from within excel. I can get the file open but how do I control where
> > the
> > > > > text goes in the word application?
> > > > >
> > > > > Thanks
> > > > >
> > > >
> > > >
> > > >
> >
> >
> >
In the VBA Editor, go to Tools>>References, and select your Microsoft Word
type library.
"Shawn G." <[email protected]> wrote in message
news:[email protected]...
> Dim Word As New Word.Application gives User-defined type not defined???
> I am using Office 2003 if that means anything.
>
>
> "Ed" wrote:
>
> > Shawn:
> >
> > This code sets an object to the Word application, and then sets and
object
> > to a single document. The object "WordDoc" is your Word document,
which
> > can be manipulated using the Word object model. If you've set the
library
> > reference to Word, then the Word objects, properties, and methods are
> > available in the VBA Editor (such as my "Dim rng As Word.Range". Also
note
> > the ending code.
> >
> > Ed
> >
> > Dim Word As New Word.Application
> > Dim WordDoc As New Word.document
> > Dim rng As Word.Range
> >
> > ''' "doc" in the following line is a string variable
> > ''' previously Dim'd and set to the desired
> > ''' document's complete file path and name
> > Set WordDoc = Word.Documents.Open(doc)
> > Word.Visible = True
> > Set rng = WordDoc.Paragraphs.Last.Range
> >
> > WordDoc.Close
> > Word.Quit
> > Set WordDoc = Nothing
> > Set Word = Nothing
> >
> >
> > "Shawn G." <[email protected]> wrote in message
> > news:[email protected]...
> > > you wouldn't happen to have an explanple would you?
> > >
> > > "Ed" wrote:
> > >
> > > > You'll have to set a library reference to the Word object library.
> > Then,
> > > > when you set an object to your document, you can use the Word object
> > model
> > > > references (line, paragraph, story, and so on) to manipulate the
ranges
> > and
> > > > text of a Word document from within Excel VBA.
> > > > Ed
> > > >
> > > > "Shawn G." <[email protected]> wrote in message
> > > > news:[email protected]...
> > > > > I need to open a word doc and insert cell values at the end of
certain
> > > > lines
> > > > > from within excel. I can get the file open but how do I control
where
> > the
> > > > > text goes in the word application?
> > > > >
> > > > > Thanks
> > > > >
> > > >
> > > >
> > > >
> >
> >
> >
Thanks!!!!!!
"Ed" wrote:
> In the VBA Editor, go to Tools>>References, and select your Microsoft Word
> type library.
>
> "Shawn G." <[email protected]> wrote in message
> news:[email protected]...
> > Dim Word As New Word.Application gives User-defined type not defined???
> > I am using Office 2003 if that means anything.
> >
> >
> > "Ed" wrote:
> >
> > > Shawn:
> > >
> > > This code sets an object to the Word application, and then sets and
> object
> > > to a single document. The object "WordDoc" is your Word document,
> which
> > > can be manipulated using the Word object model. If you've set the
> library
> > > reference to Word, then the Word objects, properties, and methods are
> > > available in the VBA Editor (such as my "Dim rng As Word.Range". Also
> note
> > > the ending code.
> > >
> > > Ed
> > >
> > > Dim Word As New Word.Application
> > > Dim WordDoc As New Word.document
> > > Dim rng As Word.Range
> > >
> > > ''' "doc" in the following line is a string variable
> > > ''' previously Dim'd and set to the desired
> > > ''' document's complete file path and name
> > > Set WordDoc = Word.Documents.Open(doc)
> > > Word.Visible = True
> > > Set rng = WordDoc.Paragraphs.Last.Range
> > >
> > > WordDoc.Close
> > > Word.Quit
> > > Set WordDoc = Nothing
> > > Set Word = Nothing
> > >
> > >
> > > "Shawn G." <[email protected]> wrote in message
> > > news:[email protected]...
> > > > you wouldn't happen to have an explanple would you?
> > > >
> > > > "Ed" wrote:
> > > >
> > > > > You'll have to set a library reference to the Word object library.
> > > Then,
> > > > > when you set an object to your document, you can use the Word object
> > > model
> > > > > references (line, paragraph, story, and so on) to manipulate the
> ranges
> > > and
> > > > > text of a Word document from within Excel VBA.
> > > > > Ed
> > > > >
> > > > > "Shawn G." <[email protected]> wrote in message
> > > > > news:[email protected]...
> > > > > > I need to open a word doc and insert cell values at the end of
> certain
> > > > > lines
> > > > > > from within excel. I can get the file open but how do I control
> where
> > > the
> > > > > > text goes in the word application?
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks