Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create file with word VBA

Status
Not open for further replies.

kalle82

Technical User
Apr 2, 2009
163
SE
Hi!

What is the code for creating a file. Not writing in it or reading it, creating it.

Thanks
 
What kind of file are you wanting "create"? A text file, a new Word Doc, a blank file, an exported file, what?
 
Within Word, to add a new document (to the Documents collection)
Code:
Documents.Add
Voila. A new document is there.

However, it is not a file. It is not a file until you save it. To save a file, you must give it a name.
Code:
Documents.Add
[COLOR=red]' this is now the Active Document[/color red]
ActiveDocument.Save Filename:=[i]valid_path_and_name[/i]
Voila, You have created a blank document file saved as the name you have given it, at the path location you have given it.

See "Working with Document Objects" in Word VBA Help.

Gerry
 
Hi sorry I was unclear in my description.

I want my vba macro to create an .ini file when i press a command button.

After its created i have some code to fill it with entitites. But my problem is really how to get my VBA macro to create the .ini file in for example c:\folder\myfile.ini

cheers Carl

 
I added an additonal comment to that thread. Note also that the file it points to does NOT have to be named as an .INI file. It can be a .txt file.

Thank you for mentioning the reference to the other thread. Very polite. Thanks for the star too.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top