For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > April 2005 > Word automation









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Word automation
Aaron Blacksmith

2005-04-25, 3:55 pm

I need to open a word document, read a multi column table and translate it
into a database table. Anyone knows where I can find sample vb code for the
Word automation part of this?


Veign

2005-04-25, 3:55 pm

What I would do is start with code like:
http://www.veign.com/vrc_codeview.asp?type=app&id=62

and then goto Word and use the Record Macro feature to get an idea of the
code required to do what you want. Should be noted that the code generated
from the Record Macro may not be the cleanest code but it does point you in
the right direction..

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


"Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
news:NU4be.135539$dP1.477803@newsc.telia.net...
> I need to open a word document, read a multi column table and translate it
> into a database table. Anyone knows where I can find sample vb code for

the
> Word automation part of this?
>
>



Aaron Blacksmith

2005-04-26, 8:56 am

I don't have a problem with the basic automation - instead my problem is
that the document I want to read stores a table in a textbox. How can I
access the table and read the contents of it, cell by cell? (tables.count
returns zero).

"Veign" <NOSPAMinveign@veign.com> wrote in message
news:%23vu3vUaSFHA.3288@TK2MSFTNGP14.phx.gbl...
> What I would do is start with code like:
> http://www.veign.com/vrc_codeview.asp?type=app&id=62
>
> and then goto Word and use the Record Macro feature to get an idea of the
> code required to do what you want. Should be noted that the code
> generated
> from the Record Macro may not be the cleanest code but it does point you
> in
> the right direction..
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
>
>
> "Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
> news:NU4be.135539$dP1.477803@newsc.telia.net...
> the
>
>



Veign

2005-04-26, 3:56 pm

Use the Record Macro and change the contents of some of the cells and see
what code is produced to access the table cells. This, again, should point
you in the right direction.

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


"Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
news:Efnbe.22675$d5.167004@newsb.telia.net...
> I don't have a problem with the basic automation - instead my problem is
> that the document I want to read stores a table in a textbox. How can I
> access the table and read the contents of it, cell by cell? (tables.count
> returns zero).
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:%23vu3vUaSFHA.3288@TK2MSFTNGP14.phx.gbl...
the[color=darkred]
>
>



Aaron Blacksmith

2005-04-27, 8:56 am

Sure - that't the default method for me as well. In this case, however, the
macro recorder seems to block the access to the textbox, so I can't make it
record how to access it. I have also tried a search for a word inside the
textbox, which works fine outside a macro, but not at all inside a macro
with the search recorded. So - unfortunately - it's status quo...

(I run office 2003 + XP.)
Aaron




"Veign" <NOSPAMinveign@veign.com> wrote in message
news:OdSAu1mSFHA.2000@TK2MSFTNGP10.phx.gbl...
> Use the Record Macro and change the contents of some of the cells and see
> what code is produced to access the table cells. This, again, should
> point
> you in the right direction.
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
>
>
> "Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
> news:Efnbe.22675$d5.167004@newsb.telia.net...
> the
>
>



Veign

2005-04-27, 3:55 pm

This code shows accessing table cells:
http://www.word.mvps.org/faqs/macro...leCellEmpty.htm

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


"Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
news:o%Jbe.22727$d5.167347@newsb.telia.net...
> Sure - that't the default method for me as well. In this case, however,

the
> macro recorder seems to block the access to the textbox, so I can't make

it
> record how to access it. I have also tried a search for a word inside the
> textbox, which works fine outside a macro, but not at all inside a macro
> with the search recorded. So - unfortunately - it's status quo...
>
> (I run office 2003 + XP.)
> Aaron
>
>
>
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:OdSAu1mSFHA.2000@TK2MSFTNGP10.phx.gbl...
see[color=darkred]
is[color=darkred]
(tables.count[color=darkred]
>
>



Aaron Blacksmith

2005-04-27, 3:55 pm

OK - thanks - but accessing table cells is not the problem. The problem is
when the table is located inside a text box. The text box seems to hide the
table - at least I haven't found the way to get through it. Sorry for
describing the problem badly...
Aaron



"Veign" <NOSPAMinveign@veign.com> wrote in message
news:%23HCO5qzSFHA.3544@TK2MSFTNGP12.phx.gbl...
> This code shows accessing table cells:
> http://www.word.mvps.org/faqs/macro...leCellEmpty.htm
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
>
>
> "Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
> news:o%Jbe.22727$d5.167347@newsb.telia.net...
> the
> it
> see
> is
> (tables.count
>
>



Veign

2005-04-27, 3:55 pm

I guess I don't know enough about tables in Word to properly answer your
question. I can't seem to visualize a table inside of a textbox. Your best
course of action would be to post this question in the Word programming /
VBA newsgroup as those guys would have a better understanding of the Word
API..

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


"Aaron Blacksmith" <Aaron@___Nospam.com> wrote in message
news:FbPbe.22744$d5.167423@newsb.telia.net...
> OK - thanks - but accessing table cells is not the problem. The problem is
> when the table is located inside a text box. The text box seems to hide

the
> table - at least I haven't found the way to get through it. Sorry for
> describing the problem badly...
> Aaron
>
>
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:%23HCO5qzSFHA.3544@TK2MSFTNGP12.phx.gbl...
make[color=darkred]
the[color=darkred]
macro[color=darkred]
problem[color=darkred]
can[color=darkred]
point[color=darkred]
code[color=darkred]
>
>



NickHK

2005-04-28, 3:56 am

Aaron,
The only thing I can see is:
'Select the desired text box
ActiveDocument.Shapes(1).Select
'Manipulate the table data
Selection.Tables.Count

There seems no way to access the .Table from .Shape without going through the Selection object.

NickHK

On Wed, 27 Apr 2005 16:35:49 GMT, "Aaron Blacksmith" <Aaron@___Nospam.com> wrote:

>OK - thanks - but accessing table cells is not the problem. The problem is
>when the table is located inside a text box. The text box seems to hide the
>table - at least I haven't found the way to get through it. Sorry for
>describing the problem badly...
>Aaron
>
>
>
>"Veign" <NOSPAMinveign@veign.com> wrote in message
>news:%23HCO5qzSFHA.3544@TK2MSFTNGP12.phx.gbl...
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com