Please answer: does FreeFile create Word doc?

E

Ed

If I use FreeFile to create, write to, and close a document within a Word
macro, does it create a Word document? If not, what kind of document is it?
I know I have to add the ".doc" onto the file name when its created, but is
it a Word doc?

Ed
 
J

Jay Freedman

Hi Ed

Emphatically NO, it is not a Word doc. If you want a Word doc, use the
Documents.Add method.

Strictly speaking, FreeFile doesn't create any file at all. It returns
a number that you can use in VBA's Open command -- and I strongly
recommend that you read the VBA help topic for that command. To help
you understand what you'll find there, here's a little ramble:

The Open command can open (or create, if the specified file path/name
doesn't already exist) *any* kind of file. Most often it's used with
plain text files, but it can open "binary" files such as Word docs,
database files, or even executables. The trick is to be able to
understand the data you read from the file, or to be able to write to
it in the correct format. It's *very* unlikely you would be able to
write successfully to a Word doc this way.

The Open command associates the file's name with a file number, which
can be any number you want from 1 to 511. You use that number in all
the commands that read from and write to the file. If you have two or
more files open at the same time, you need to make sure the numbers
are distinct, and that's what FreeFile is for.
 
E

Ed

Thanks, Jay. I did read the Help for Open, and it was definitely
noncommittal about the document type, so I thought I should ask. I thought
I had the answer to my 12,000-loop problem (I couldn't raise an answer in
VBA.General, so I posted this here; thought maybe folks were getting tired
of seeing me come back on this) - I ran through 2,000 loops in just over a
minute, vice 18 1/2 minutes for SaveAs wdDocument.

Oh, well - when I can get by with a generic text doc, I've learned how to do
that. I appreciate the response.

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top