Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |