word normal dot problem

T

Tolga Ongunsu

Why this code makes an overload the application proccess menu? And in Win XP
it always want to save document as normal.dot?

Please tell me where is the problem and how can i solve it...?

Thanks

Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
Set oWordApp = New Word.Application

With oWordApp

Set oWordDoc = .Documents.Add
End With

..
..
..
temp = dral & "\" & firma & ".doc"

.SaveAs temp

.Close
End With
Set oWordDoc = Nothing

oWordApp.Quit
Set oWordApp = Nothing
 
A

Andrew Cushen

You need to post the rest of your code, or we can't tell
if you've done certain things correctly.

Your code won't work if there isn't already an instance of
Word running. Code like this will handle that situation:

'--------------------------------------------------
Dim oWordApp As Word.Application
On Error Resume Next

Set oWordApp = Word.Application
If oWordApp Is Nothing Then Set oWordApp = New
Word.Application
'---------------------------------------------------

Also, does the directory referred to by "dral" definitely
exist one directory above the current one? Have you set
the current directory? It's usually better to either refer
to the directory the program is running in by using
App.Path, or, if you absolutely have to, to hard-code the
directory in a Constant at the top of the file.

Try posting the rest of your code.


-Andrew
===================================================
 
A

Andrew Cushen

The following version of your code worked for me, and
placed the document in a folder called "tstfldr" in My
Documents. Note that the folder MUST exist before you run
the code.

'-------------------------------------------------
Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
On Error Resume Next

Set oWordApp = Word.Application
If oWordApp Is Nothing Then Set oWordApp = New
Word.Application
oWordApp.Visible = True

With oWordApp

Set oWordDoc = .Documents.Add
End With


Dim temp As String, dral As String, firma As String
dral = "tstfldr"
firma = "testdocname"
temp = dral & "\" & firma & ".doc"


With oWordDoc
.SaveAs temp

.Close
End With
Set oWordDoc = Nothing

oWordApp.Quit
Set oWordApp = Nothing
'----------------------------------------------------

HTH,

-Andrew
=====================================================
 

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