?
Solved

How to create a  word new document(.doc) through VB?.     VBA

Posted on 2003-03-10
6
Medium Priority
?
245 Views
Last Modified: 2010-05-01
How to create a  new word document(.doc) through VB?.

if anyone knows please help me.

Advanced  thanks,


Thanks,
Merlin
0
Comment
Question by:merlin_vb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:graham_charles
ID: 8101891
   Dim newApp As Object  
    Set newApp = CreateObject("Word.Application")
    newApp.Documents.Add
    newApp.Visible = True

You can also just use

   Dim newApp As Word.Application

...but you'd need to include the Microsoft Word object library in your application.

Now, the only question is... what do you want to do with the new document?

g.
0
 
LVL 11

Expert Comment

by:Steiner
ID: 8103034
Some additional thoughts:
If you want to work further with your newly created document, I'd advise to create an object for that document, too.

After including the library like g. said, use the following code example:


Sub UseWord()
   Dim WdApp As Word.Application, WdDoc As Word.Document
   
   Set WdApp = CreateObject("Word.Application")
   WdApp.Visible = True
   
   Set WdDoc = WdApp.Documents.Add  'up to here the same as g.
   With WdDoc
      'Do what you want with the document
      .Range.Text = "That's a new document..."
   End With
   
   
   'Some cleanup, you could close Word via WdApp.Quit if you like, or save the doc
   'WdDoc.Save
   'WdApp.Quit
   Set WdDoc = Nothing
   Set WdApp = Nothing
End Sub
0
 

Expert Comment

by:Siebe
ID: 8119937
If you just need to create a new document and no further editing of it, why don't you just put an empty document in your app path and then let it copy to where ever you want to be 'created'.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:CleanupPing
ID: 8900403
merlin_vb:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9074650
merlin_vb, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9165961
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question