Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 772
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 47
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 772
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 47
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Helps: Type Mismatch Error Jurassien Excel Discussion (Misc queries) 1 March 15th 07 07:30 PM
Macro error type mismatch Jurassien Excel Discussion (Misc queries) 3 February 23rd 07 08:14 PM
FIND type mismatch error, but don't see it KathyC Excel Worksheet Functions 7 November 14th 06 03:59 PM
Type Mismatch Error David Excel Discussion (Misc queries) 2 December 11th 05 04:46 PM
Why type mismatch - R/T error 13 Jim May Excel Discussion (Misc queries) 5 January 9th 05 06:45 PM


All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"