Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Type Mismatch Error - Help Please
Hi . . .
The all CAPS area states what the problem is. Can someone help please. Sub NewWordWithDocument() Dim oWordApp As Object Dim oWordDoc As Object Set oWordApp = CreateObject("Word.Application") ' oWordApp.Visible = True ' Set oWordDoc = oWordApp.Documents.Open( _ ' "C:\documents and settings\default\my documents\CompClassChurchBulletin. doc") 'WITH THE PATH AND DOCUMENT HARD CODED AS ABOVE, IT WORKED, BUT HAD NO TESTING. 'FROM HERE DOWN THE TESTING WORKS FINE. 'THEN, WHEN IT GETS TO THE LAST LINE OF CODE WHICH IS TO OPEN THE FILE IN THE ACTIVECELL. 'AN ERROR MESSAGE IS DISPLAYED: "Type Mismatch" 'I CLICK DEBUG AND THE LAST LINE OF CODE IS HIGHLITED IN YELLOW. 'I DON'T KNOW WHAT I DID WRONG. Dim testFileFind Dim oWB As Object ActiveCell.Offset(0, -1).Activate 'this moves the selected cell 1 cell to the Left 'The following tests for a blank cell and ends processing 'It is needed because dir() function will not work with a blank. If Len(Trim(ActiveCell)) = 0 Then MsgBox "Active Cell " & ActiveCell.Address & " is blank. You have not entered a Path & File Name." End End If 'The following tests for the existance of the file testFileFind = Dir(ActiveCell) 'If the file is not found there will be nothing 'in the variable and processing ends. If Len(testFileFind) = 0 Then MsgBox "Invalid selection." & Chr(13) & _ "Filename " & ActiveCell & " not found" End End If 'THIS LINE OF CODE OPENS THE NEW INSTANCE OF WORD. Set oWordApp = CreateObject("Word.Application") 'THIS LINE OF CODE MAKES THE NEW INSTANCE OF WORD VISIBLE. oWordApp.Visible = True Set oWordDoc = oWordApp.Documents.Open(ActiveCell) End Sub Can someone find the "Type Mismatch" whatever that means. Thanks Matt@Launchnet -- Message posted via http://www.officekb.com |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Type Mismatch Error - Help Please
The problem really has to be the string in Activecell, ensure that it is
correct, post it if you are not sure. Easy way to test is to change the name of the file to like 123 and make sure it works. -- -John Please rate when your question is answered to help us and others know what is helpful. "Launchnet" wrote: Hi . . . The all CAPS area states what the problem is. Can someone help please. Sub NewWordWithDocument() Dim oWordApp As Object Dim oWordDoc As Object Set oWordApp = CreateObject("Word.Application") ' oWordApp.Visible = True ' Set oWordDoc = oWordApp.Documents.Open( _ ' "C:\documents and settings\default\my documents\CompClassChurchBulletin. doc") 'WITH THE PATH AND DOCUMENT HARD CODED AS ABOVE, IT WORKED, BUT HAD NO TESTING. 'FROM HERE DOWN THE TESTING WORKS FINE. 'THEN, WHEN IT GETS TO THE LAST LINE OF CODE WHICH IS TO OPEN THE FILE IN THE ACTIVECELL. 'AN ERROR MESSAGE IS DISPLAYED: "Type Mismatch" 'I CLICK DEBUG AND THE LAST LINE OF CODE IS HIGHLITED IN YELLOW. 'I DON'T KNOW WHAT I DID WRONG. Dim testFileFind Dim oWB As Object ActiveCell.Offset(0, -1).Activate 'this moves the selected cell 1 cell to the Left 'The following tests for a blank cell and ends processing 'It is needed because dir() function will not work with a blank. If Len(Trim(ActiveCell)) = 0 Then MsgBox "Active Cell " & ActiveCell.Address & " is blank. You have not entered a Path & File Name." End End If 'The following tests for the existance of the file testFileFind = Dir(ActiveCell) 'If the file is not found there will be nothing 'in the variable and processing ends. If Len(testFileFind) = 0 Then MsgBox "Invalid selection." & Chr(13) & _ "Filename " & ActiveCell & " not found" End End If 'THIS LINE OF CODE OPENS THE NEW INSTANCE OF WORD. Set oWordApp = CreateObject("Word.Application") 'THIS LINE OF CODE MAKES THE NEW INSTANCE OF WORD VISIBLE. oWordApp.Visible = True Set oWordDoc = oWordApp.Documents.Open(ActiveCell) End Sub Can someone find the "Type Mismatch" whatever that means. Thanks Matt@Launchnet -- Message posted via http://www.officekb.com |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Type Mismatch Error - Help Please
Thanks . . .
I have tried numerous paths & files and they all do the same thing. I have the code for doing this in Excel, opening and Excel file and it works fine. Any other ideas. Maybe it has to do with the object. John Bundy wrote: The problem really has to be the string in Activecell, ensure that it is correct, post it if you are not sure. Easy way to test is to change the name of the file to like 123 and make sure it works. Hi . . . [quoted text clipped - 64 lines] Thanks Matt@Launchnet -- Please take a look at www.openoursite.com Click on: "Keywords" and then Click on "Matt's Story" and if you are a man, you should be very happy that you read my story. God Bless for everyones help. Message posted via http://www.officekb.com |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Type Mismatch Error - Help Please
DOH!! Tried it again and it didn't work, activecell.text did
-- -John Please rate when your question is answered to help us and others know what is helpful. "Launchnet via OfficeKB.com" wrote: Thanks . . . I have tried numerous paths & files and they all do the same thing. I have the code for doing this in Excel, opening and Excel file and it works fine. Any other ideas. Maybe it has to do with the object. John Bundy wrote: The problem really has to be the string in Activecell, ensure that it is correct, post it if you are not sure. Easy way to test is to change the name of the file to like 123 and make sure it works. Hi . . . [quoted text clipped - 64 lines] Thanks Matt@Launchnet -- Please take a look at www.openoursite.com Click on: "Keywords" and then Click on "Matt's Story" and if you are a man, you should be very happy that you read my story. God Bless for everyones help. Message posted via http://www.officekb.com |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Type Mismatch Error - Help Please
Hi John . . .
Just a WORD of Thanks. I tested it and it seems to work fine. I will give it a very good test just to be sure. Many thanks again. Matt@Launchnet John Bundy wrote: DOH!! Tried it again and it didn't work, activecell.text did Thanks . . . I have tried numerous paths & files and they all do the same thing. I have [quoted text clipped - 10 lines] Thanks Matt@Launchnet -- Please take a look at www.openoursite.com Click on: "Keywords" and then Click on "Matt's Story" and if you are a man, you should be very happy that you read my story. God Bless for everyones help. Message posted via http://www.officekb.com |
#6
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Type Mismatch Error - Help Please
I think we discussed these SpecialFolders before.
On my system there is no such path as "C:\documents and settings\default\my documents\.." It is "C:\Documents and Settings\Default User\My Documents\... Depending on how you are getting/setting this path, it may not work on all systems. NickHK "Launchnet" <u20911@uwe wrote in message news:756365f5dbc08@uwe... Hi . . . The all CAPS area states what the problem is. Can someone help please. Sub NewWordWithDocument() Dim oWordApp As Object Dim oWordDoc As Object Set oWordApp = CreateObject("Word.Application") ' oWordApp.Visible = True ' Set oWordDoc = oWordApp.Documents.Open( _ ' "C:\documents and settings\default\my documents\CompClassChurchBulletin. doc") ---------- CUT ---------------- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Helps: Type Mismatch Error | Excel Discussion (Misc queries) | |||
Macro error type mismatch | Excel Discussion (Misc queries) | |||
FIND type mismatch error, but don't see it | Excel Worksheet Functions | |||
Type Mismatch Error | Excel Discussion (Misc queries) | |||
Why type mismatch - R/T error 13 | Excel Discussion (Misc queries) |