2012-09-28 53 views
1

我一直在試圖找出在Intranet上顯示電源點的最佳方式。該公司的用戶不會很技術,可能不會遵循我將要描述的流程。我可以自動將.ppt轉換爲.html嗎?

我發現這個page

它展示瞭如何電源點轉換到其可以被看作一個HTML頁面。我想知道是否有某種方法可以使這個過程自動化。比如一個文件觀察者看着它將要保存的位置,然後一旦它被看到,就會自動將它改變爲使用我給出的頁面上提供的代碼的html。首選語言是VB.NET。

我很高興任何人可以給的建議。

在此先感謝

+0

現有的軟件包可以做到這一點:Alfresco,SharePoint,Confluence,http://slideshare.net,OpenOffice ... – MarkJ

回答

0

,我用了:

Imports PowerPoint = Microsoft.Office.Interop.PowerPoint 

能夠在一個HTML自動改變受力點。我已經使用文件觀察器來觀看我的計算機上的目錄,以便在僅設置爲.pptx的時刻查找功率點演示文稿,但是我會盡快更改此格式以添加其他格式。這個fileWater位於計算機啓動的服務上。然後,它會查看是否一個PowerPoint已創建或修改,並運行此代碼:

Private Shared Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs) 
    'set varaibles so that html can save in correct place 
    Dim destinationDirectory As String = e.FullPath.Replace(e.Name.ToString(), "") 
    Dim sourceLocation As String 
    Dim fileName As String 
    'couple of if statements to get rid of unwanted characters 
    If e.Name.Contains("~$") Then 
     fileName = e.Name.Replace("~$", "") 
     fileName = fileName.Replace(".pptx", ".html") 
    Else 
     fileName = e.Name 
     fileName = fileName.Replace(".pptx", ".html") 
    End If 

    If e.FullPath.Contains(("~$")) Then 
     sourceLocation = e.FullPath.Replace("~$", "") 
    Else 
     sourceLocation = e.FullPath 
    End If 

    Dim strSourceFile As String = sourceLocation 'set source location after removing unwanted characters 
    Dim strDestinationFile As String = destinationDirectory & fileName 'set the destination location with the directory and file name 
    'set ppAPP to a power point application 
    Dim ppApp As PowerPoint.Application = New PowerPoint.Application 
    Dim prsPres As PowerPoint.Presentation = ppApp.Presentations.Open(strSourceFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse) 
    'Call the SaveAs method of Presentaion object and specify the format as HTML 
    prsPres.SaveAs(strDestinationFile, PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTrue) 
    'Close the Presentation object 
    prsPres.Close() 
    'Close the Application object 
    ppApp.Quit() 

End Sub 

這得到已被修改的文件,並將其保存爲HTML文檔。它也將獲得運行所需的文件,如果任何動畫已保存,它也會保留這些文件。

1

您可以使用此代碼嘗試 - 基於Microsoft.Office.Interop.PowerPoint.Application

你才能嘗試的功能

查看.aspx的

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AspNetPowerPointConvertToHTML.aspx.vb" Inherits="AspNetPowerPointConvertToHTML" %> 
<html> 
<head> 
<title>ShotDev.Com Tutorial</title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<asp:Label id="lblText" runat="server"></asp:Label> 
</form> 
</body> 
</html> 

代碼背後有代碼示例

Imports Microsoft.Office.Interop.PowerPoint 
Public Class AspNetPowerPointConvertToHTML 
Inherits System.Web.UI.Page 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

Dim ppApp As New Microsoft.Office.Interop.PowerPoint.Application 
Dim ppName As String = "MySlides.ppt" 
Dim FileName As String = "MyPP/MyPPt" 

ppApp.Visible = True 

ppApp.Presentations.Open(Server.MapPath(ppName)) 
ppApp.ActivePresentation.SaveAs(Server.MapPath(FileName), 13) 
ppApp.Quit() 
ppApp = Nothing 

Me.lblText.Text = "PowerPoint Created to Folder <strong> " & FileName & "</strong>" 

End Sub 
End Class 
+0

我還沒有嘗試過,但它看起來可能會工作。我設法做了一些不同的事情。 – TeamGB

相關問題