How to open and read a word doc in a vba loop 
Author Message
 How to open and read a word doc in a vba loop

OK, I don't know if this is blindingly simple, or I'm
barking up the wrong tree.

I'm a VB programmer who has never used VBA before. I want
to write a short vba module to open a document, search
for index some stuff based on where it is placed in the
document (column position), and then save each page as a
htm file.

And I'm stuck on the first step. How do yo open a
document in vba? I've tried the simple "open 'thisfile'
for input as #1 stuff with a line input statement...but I
keep getting read past end of file errors. Me thinks I'm
going about this the wrong way. Can anyone offer any
advice?

Thx!



Thu, 24 Jun 2004 19:14:19 GMT  
 How to open and read a word doc in a vba loop

dz,

What you want is:

   Documents.Open Filename:="__________"

You're probably also gonna run into the obstacle posed by
the fact that there is no 'page' object in Word VBA. For
help getting around that, see:

http://www.mvps.org/word/FAQs/MacrosVBA/SelectCurPage.htm

Hope this helps a little.


-- See the MVP FAQ at http://www.mvps.org/word -------------
---- "Life is nothing if you're not obsessed." --John Waters
------------------------------------------------------------
Reply to newsgroup only.  NB: MVPs do not work for Microsoft.

Quote:

> OK, I don't know if this is blindingly simple, or I'm
> barking up the wrong tree.

> I'm a VB programmer who has never used VBA before. I want
> to write a short vba module to open a document, search
> for index some stuff based on where it is placed in the
> document (column position), and then save each page as a
> htm file.

> And I'm stuck on the first step. How do yo open a
> document in vba? I've tried the simple "open 'thisfile'
> for input as #1 stuff with a line input statement...but I
> keep getting read past end of file errors. Me thinks I'm
> going about this the wrong way. Can anyone offer any
> advice?

> Thx!



Thu, 24 Jun 2004 19:31:00 GMT  
 How to open and read a word doc in a vba loop
In addition to Mark's tips, also note that if you set a reference in your VB
project to Word, you will get access to intellisense, so that if you type,
for instance, an object name followed by a dot - such as Documents. - a list
will pop up of all the supported methods and properties for the object; for
you to pick from (this even works with variable names for object variables,
as long as you declare your variables properly:
http://www.mvps.org/word/FAQs/MacrosVBA/DeclareVariables.htm); and if you
click on a keyword in your code and press F1, the Help topic on that keyword
will open; and you will also have access to all Word's objects, properties
and methods in the Object Browser. Also see:
http://www.mvps.org/word/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

Regards

Dave


| OK, I don't know if this is blindingly simple, or I'm
| barking up the wrong tree.
|
| I'm a VB programmer who has never used VBA before. I want
| to write a short vba module to open a document, search
| for index some stuff based on where it is placed in the
| document (column position), and then save each page as a
| htm file.
|
| And I'm stuck on the first step. How do yo open a
| document in vba? I've tried the simple "open 'thisfile'
| for input as #1 stuff with a line input statement...but I
| keep getting read past end of file errors. Me thinks I'm
| going about this the wrong way. Can anyone offer any
| advice?
|
| Thx!
|



Thu, 24 Jun 2004 20:42:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Reading a Word Doc Line by Line in VBA

2. Open a word doc in read-only in browser

3. To open EXCEL or WORD doc read-onl

4. Getting Word to open a doc with VBA

5. vba code missing after opening a word template as doc

6. Opening embedded Word Doc in Powerpoint Slideshow using VBA

7. MS Word VBA: Looping through opened Windows

8. MS Word VBA: Looping through opened Windows

9. MS Word VBA: Looping through opened Windows

10. Open word 97 doc with doc name as variable

11. Excel open .doc or word open .xls?

12. Printing multiple Word doc files without opening each in word

 

 
Powered by phpBB® Forum Software