Saving documents on server side.

来源:http://www.imcoder.org/enterprise-service/210201.htm

 

Q:

** Warning: possibly big newbie question below. **

Greetings,

Part of a web application I am developing involves generation of word documents (which I do using Word COM object) based on data provided by the client and then the application has to store them on the server.

However, I have yet to find the proper way in which to provide the paths needed both to save the document on the server and to load the template. I thought something like 'folder-to-store-stuff/document.doc' or '/folder-to-store-stuff/document.doc' would work but..well, it didn't (Folders exist on the application path, so it's not that they weren't created).

It is not a folder permission issue, the errors I get are that either the path is unreachable or that it cannot create the instance of Document because of not being able to find the path.

Any kind of help or directions would be greatly appreciated.

A:Hello, Can you please post some of your code so we can look at how your referenceing to the location of the folders.
A:

Greetings,

This is the method I created for the generation of the documents.

Sub

createDocument(ByVal empresa As String, ByVal contacto As String, ByVal pasante As String, ByVal tutor As String, ByVal duracion As String, ByVal desde As String, ByVal hasta As String)

Dim wa As New Word.ApplicationClass
Dim oTemplate As String = "/Documents/Templates/Template.dot"
Dim wd As Word.Document = wa.Documents.Add(oTemplate)
Dim ruta As String
ruta = "/Documents/Contract Documents/Contract" & AdministradorPasantias.getObject.getPasante.idPasante.ToString & AdministradorPasantias.getObject.getPasante.idPasantia.ToString & ".doc"

Try
   wd.Activate()
   'Assigns to each bookmark the corresponging value from the form.

   wd.Bookmarks.Item("observaciones").Range.Text = objInforme.observaciones
   
wd.Bookmarks.Item("empresa").Range.Text = empresa
   
wd.Bookmarks.Item("contacto").Range.Text = contacto
   
wd.Bookmarks.Item("pasante").Range.Text = pasante
   
wd.Bookmarks.Item("duracion").Range.Text = duracion
   
wd.Bookmarks.Item("tutor").Range.Text = tutor
   
wd.Bookmarks.Item("desde").Range.Text = desde
   
wd.Bookmarks.Item("hasta").Range.Text = hasta
   
wd.SaveAs(ruta)
   
wd.Application.Quit()
Catch ex As Exception

End Try
End Sub

The directory where I have the application has the corresponding "/Documents/Templates/" and "/Documents/Contract Documents/" inside.

Again, any kind of help will be greatly appreciated. I'm sure I must be missing something simple but..well, I'm stuck.

你可能感兴趣的:(document)