URGENT: MSWORD Query

The following function opens a word document

Public Function OpenNewDoc(Optional docname As String, Optional ro As Boolean = False, Optional atrfl As Boolean = False, Optional bVisible As Boolean = True)

    If Len(docname) > 0 Then
        Set wrdDoc = wrdApp.Documents.Open(docname, ReadOnly:=ro, addtorecentfiles:=atrfl)
    Else
        Set wrdDoc = wrdApp.Documents.Add
        wrdDoc.Select
        Set wrdSelection = wrdApp.Selection
    End If

 wrdApp.Visible = bVisible

End Function

What I would like to do, is open a template document, save it with a predefined file name, and then open the document ...

As much as I can I would also like to use the word object itself to do this ...

I am using Word 11.

Regards

DWE
LVL 1
dwe0608Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bruintjeCommented:
Hello dwe0608,

i assume you want to be able to add that functionality to the part if there is no docname supplied? then you can do this

---------
Public Function OpenNewDoc(Optional docname As String, Optional ro As Boolean = False, Optional atrfl As Boolean = False, Optional bVisible As Boolean = True)
Dim wrdApp As Application
Dim wrdDoc As Document
    If Len(docname) > 0 Then
        Set wrdDoc = wrdApp.Documents.Open(docname, ReadOnly:=ro, addtorecentfiles:=atrfl)
    Else
        Set wrdDoc = wrdApp.Documents.Add(Template:="c:\mytemplate.dot")
        wrdDoc.Select
        Set wrdSelection = wrdApp.Selection
    End If

 wrdApp.Visible = bVisible

End Function
----------

this line

        Set wrdDoc = wrdApp.Documents.Add(Template:="c:\mytemplate.dot")

will open a new document based on the template provided, you can also use something like Template:="c:\mytemplate.doc"

key is that if you leave it empty as in your original it will use the empty normal.dot by default

hope this helps a bit
bruintje

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dwe0608Author Commented:
Yes, it does ....

Is there a definative resource for msword which talks about using vb and msword ?
bruintjeCommented:
good question, i'm not sure

what i mostly do is using the object browser in the ms office application [F2 in the vb editor]
most of the info i learned from there, if you can make things work in the office app then port it to VB or any other environment

otherwise i google for the thing i need to know, because most of the time its something that should've been done by others already :-)
and use google groups instead of plain google, the group search is really helpful in finding relevant snippets

thanks for the grade

dwe0608Author Commented:
thanks for the prompt response... I will try those mthods of search ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.