Found the answer, from John Lundy . . .
All I had to do was ADD: .text to the last line of code after
ActiveCell.text
Thanks Everyone
Matt@Launchnet
Launchnet wrote:
THE NEXT STEP . . .
I needed the same procedure for opening a word document just like in Excel.
So, I modified the code and all works EXCEPT . . .PLEASE read my explaination
Can you give me a hand again ?
Thanks
Matt@Launchnet
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 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 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
Try this to check that the file exists. Insert it as the first code in the
sub and then processing will terminate before it attempts to open anything if
[quoted text clipped - 32 lines]
End Sub
--
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