Saving documents on server side.

來源:互聯網
上載者:User

來源: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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.