Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
open word from excel...file does not exist error
I am trying to open a word dopcument from excel...below is the code I am
running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
open word from excel...file does not exist error
Hi, im using this and it's working. Don't use CreateObject but GetObject like
this: Dim Word As Object Dim MyXL As Object Sub Open_Wordfile() Set Word = GetObject("C:\Documents and Settings\files\Test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub €žtbaam" napĂ*sal (napĂ*sala): I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
open word from excel...file does not exist error
First, thank you for trying to help me...
I tried exactly what you have here and now I get Run-Time error 432 Filename or class name not found during automation operation. Any other suggestions would be greatly appreciated. "Henrich" wrote: Hi, im using this and it's working. Don't use CreateObject but GetObject like this: Dim Word As Object Dim MyXL As Object Sub Open_Wordfile() Set Word = GetObject("C:\Documents and Settings\files\Test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub €žtbaam" napĂ*sal (napĂ*sala): I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
open word from excel...file does not exist error
Hi, I have tryid my code also in Office 2003 and it was working properly
(with other path and other file then before). Check your path and the file name. Henrich €žtbaam" napĂ*sal (napĂ*sala): First, thank you for trying to help me... I tried exactly what you have here and now I get Run-Time error 432 Filename or class name not found during automation operation. Any other suggestions would be greatly appreciated. "Henrich" wrote: Hi, im using this and it's working. Don't use CreateObject but GetObject like this: Dim Word As Object Dim MyXL As Object Sub Open_Wordfile() Set Word = GetObject("C:\Documents and Settings\files\Test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub €žtbaam" napĂ*sal (napĂ*sala): I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
open word from excel...file does not exist error
Are you sure it's 524 and not 424?
If the error is really 424, it could be because you misspelled WordApp in the ..visible line. (I don't get 524 when the file doesn't exist (Office 2003).) tbaam wrote: I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please don't give up on me yet!
So I changed the code to this
Sub Open_Wordfile() Dim Word As Object Dim MyXL As Object Set Word = GetObject("C:\Documents and Settings\files\test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub The file does exist but I now receive the following error: Run-time error 432 "File name or class name not found during automation operation" ....looked for info on this and found that I need this dll. regsvr32.exe C:\WINDOWS\SYSTEM\Dao360.dll I installed it and it said it was correct.... but i still get the error...any ideas "Dave Peterson" wrote: Are you sure it's 524 and not 424? If the error is really 424, it could be because you misspelled WordApp in the ..visible line. (I don't get 524 when the file doesn't exist (Office 2003).) tbaam wrote: I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please don't give up on me yet!
I saved this from a previous post. Maybe it'll help you:
Option Explicit Sub testme() 'Dim WDApp As Word.Application 'Dim WDDoc As Word.Document Dim WDApp As Object Dim WDDoc As Object Dim myDocName As String Dim myPWD As String Dim WordWasRunning As Boolean Dim testStr As String myDocName = "C:\my documents\word\doc10.doc" myPWD = "mypassword" testStr = "" On Error Resume Next testStr = Dir(myDocName) On Error GoTo 0 If testStr = "" Then MsgBox "Word file not found!" Exit Sub End If WordWasRunning = True On Error Resume Next Set WDApp = GetObject(, "Word.Application") If Err.Number < 0 Then Set WDApp = CreateObject("Word.Application") WordWasRunning = False End If WDApp.Visible = True 'at least for testing! Set WDDoc = WDApp.documents.Open(Filename:=myDocName) WDDoc.WritePassword = myPWD WDDoc.Close savechanges:=True If WordWasRunning Then 'leave it running Else WDApp.Quit End If Set WDDoc = Nothing Set WDApp = Nothing End Sub The purpose of this code was to open a file and give it a password. But there might be something that you can use. tbaam wrote: So I changed the code to this Sub Open_Wordfile() Dim Word As Object Dim MyXL As Object Set Word = GetObject("C:\Documents and Settings\files\test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub The file does exist but I now receive the following error: Run-time error 432 "File name or class name not found during automation operation" ...looked for info on this and found that I need this dll. regsvr32.exe C:\WINDOWS\SYSTEM\Dao360.dll I installed it and it said it was correct.... but i still get the error...any ideas "Dave Peterson" wrote: Are you sure it's 524 and not 424? If the error is really 424, it could be because you misspelled WordApp in the ..visible line. (I don't get 524 when the file doesn't exist (Office 2003).) tbaam wrote: I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub -- Dave Peterson -- Dave Peterson |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please don't give up on me yet!
PERFECT!!!!!!!
Thank You "Dave Peterson" wrote: I saved this from a previous post. Maybe it'll help you: Option Explicit Sub testme() 'Dim WDApp As Word.Application 'Dim WDDoc As Word.Document Dim WDApp As Object Dim WDDoc As Object Dim myDocName As String Dim myPWD As String Dim WordWasRunning As Boolean Dim testStr As String myDocName = "C:\my documents\word\doc10.doc" myPWD = "mypassword" testStr = "" On Error Resume Next testStr = Dir(myDocName) On Error GoTo 0 If testStr = "" Then MsgBox "Word file not found!" Exit Sub End If WordWasRunning = True On Error Resume Next Set WDApp = GetObject(, "Word.Application") If Err.Number < 0 Then Set WDApp = CreateObject("Word.Application") WordWasRunning = False End If WDApp.Visible = True 'at least for testing! Set WDDoc = WDApp.documents.Open(Filename:=myDocName) WDDoc.WritePassword = myPWD WDDoc.Close savechanges:=True If WordWasRunning Then 'leave it running Else WDApp.Quit End If Set WDDoc = Nothing Set WDApp = Nothing End Sub The purpose of this code was to open a file and give it a password. But there might be something that you can use. tbaam wrote: So I changed the code to this Sub Open_Wordfile() Dim Word As Object Dim MyXL As Object Set Word = GetObject("C:\Documents and Settings\files\test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub The file does exist but I now receive the following error: Run-time error 432 "File name or class name not found during automation operation" ...looked for info on this and found that I need this dll. regsvr32.exe C:\WINDOWS\SYSTEM\Dao360.dll I installed it and it said it was correct.... but i still get the error...any ideas "Dave Peterson" wrote: Are you sure it's 524 and not 424? If the error is really 424, it could be because you misspelled WordApp in the ..visible line. (I don't get 524 when the file doesn't exist (Office 2003).) tbaam wrote: I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub -- Dave Peterson -- Dave Peterson |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
open word from excel...file does not exist error
Curt:
You might need a reference in the VB to Microsoft Word # Object Library. (Mine is 11.0, your # might be different) I had to create that reference before it would work for me. HTH, Jana Curt wrote: only change i make is Set Word = GetObject("A:\desc.doc") desc.doc is a word file for paper size to import later to excel for printing in a mail merge. it says file not found or can't run etc do not understand why only change is location why won't work. maybe my excel program corrupt?? Seem ok. been fighting this a while stumped. something simple I am sure Thanks "Henrich" wrote: Hi, im using this and it's working. Don't use CreateObject but GetObject like this: Dim Word As Object Dim MyXL As Object Sub Open_Wordfile() Set Word = GetObject("C:\Documents and Settings\files\Test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub ,,tbaam" napísal (napísala): I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Please don't give up on me yet!
The first declarations (As Word.Application) expect to have a referent to
microsoft word. Open that workbook go into the VBE select that project tools|References Look for Microsoft Word and check it. Alternatively, you could just use the "as object" lines and it should work ok. Curt wrote: copied code and ran first line Dim WDApp As Word.Application gave error user defined type not defined Went back and noticed ' in front of Dim put it back in then 2nd line gave same error. Went back and removed '. I am stumped as to why this machine of mine will find the file on A but so much problem on C. I read something about a reference to something by someone any ideas "Dave Peterson" wrote: I saved this from a previous post. Maybe it'll help you: Option Explicit Sub testme() 'Dim WDApp As Word.Application 'Dim WDDoc As Word.Document Dim WDApp As Object Dim WDDoc As Object Dim myDocName As String Dim myPWD As String Dim WordWasRunning As Boolean Dim testStr As String myDocName = "C:\my documents\word\doc10.doc" myPWD = "mypassword" testStr = "" On Error Resume Next testStr = Dir(myDocName) On Error GoTo 0 If testStr = "" Then MsgBox "Word file not found!" Exit Sub End If WordWasRunning = True On Error Resume Next Set WDApp = GetObject(, "Word.Application") If Err.Number < 0 Then Set WDApp = CreateObject("Word.Application") WordWasRunning = False End If WDApp.Visible = True 'at least for testing! Set WDDoc = WDApp.documents.Open(Filename:=myDocName) WDDoc.WritePassword = myPWD WDDoc.Close savechanges:=True If WordWasRunning Then 'leave it running Else WDApp.Quit End If Set WDDoc = Nothing Set WDApp = Nothing End Sub The purpose of this code was to open a file and give it a password. But there might be something that you can use. tbaam wrote: So I changed the code to this Sub Open_Wordfile() Dim Word As Object Dim MyXL As Object Set Word = GetObject("C:\Documents and Settings\files\test.doc") Set MyXL = GetObject(, "Word.application") MyXL.Application.Visible = True End Sub The file does exist but I now receive the following error: Run-time error 432 "File name or class name not found during automation operation" ...looked for info on this and found that I need this dll. regsvr32.exe C:\WINDOWS\SYSTEM\Dao360.dll I installed it and it said it was correct.... but i still get the error...any ideas "Dave Peterson" wrote: Are you sure it's 524 and not 424? If the error is really 424, it could be because you misspelled WordApp in the ..visible line. (I don't get 524 when the file doesn't exist (Office 2003).) tbaam wrote: I am trying to open a word dopcument from excel...below is the code I am running but I receive the following error....that is runtime error 524...which indicates that the file does not exit...but it does. I searched through the other questions and did make sure that the microsoft Word 11.0 object library is available. What am I still doing wrong. Sub OpenAWordDoc() Dim WordApp As Object, WorddDoc As Object Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open "C:\Documents and Settings\files\Test.doc" WorddApp.Visible = True End Sub -- Dave Peterson -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Command Line. How to tell to XL : If the xls file exist : Open it, if it does not exist : Create it. | Excel Programming | |||
password to open Excel file option does not exist | Excel Worksheet Functions | |||
Trying to open Excel/Word files error message "Unable to read file | Excel Discussion (Misc queries) | |||
Open One Word File from Excel | Excel Programming | |||
Graph Excel Selection, Open Word File, Embed Graph Into Word | Excel Programming |