Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word document path no found

Status
Not open for further replies.

euphie18

Programmer
May 8, 2008
2
US
i need to upload a word document file and convert into textfile and read

my program work fine while running on my localhost
but when it goes to server this app not working and give me error like this
=============================================
The document name or path is not valid. Try one or more of the following: * Check the path to make sure it was typed correctly. * On the File menu, click Open. Search for the file using this dialog box. (C:\TestCases\a.doc)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The document name or path is not valid. Try one or more of the following: * Check the path to make sure it was typed correctly. * On the File menu, click Open. Search for the file using this dialog box. (C:\TestCases\a.doc)
=================================================
this my code

Dim DocFormatFile As Object
DocFormatFile = oFile.PostedFile.FileName

Dim oWord As Word.ApplicationClass
Dim oDoc As Word.DocumentClass
Const wdFormatText = 2
Dim tempFileName As Object = "c:\temp.txt"

'create a temp file path
Dim tempFile1 As Object = (tempFileName)

oWord = New Word.ApplicationClass
oDoc = New Word.DocumentClass

oWord = CreateObject("Word.application")
oDoc = CreateObject("Word.document")

'Open uploaded file
oDoc = oWord.Documents.Open(DocFormatFile)
oDoc.SaveAs(tempFile1, wdFormatText)
oDoc.Close()
oWord.Quit()
oDoc = Nothing
oWord = Nothing
=========================================
anyone can help...?
thanks
 
Check the oFile.PostedFile.FileName.
I'm affraid that it gives you a path with this pattern:
C:\TestCases\a.doc

If the file is located in other machine (and I believe so), I think you need to change the path to something like:
http:\\MyWeb.com\TestCases\a.doc

Not so sure, but I guess so.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top