Pergunta

I created a Macro with Microsoft Word 2010:

Sub Macro1()
    Selection.WholeStory
End Sub

At the event Button1_Click I would execute the macro :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Selection.WholeStory        
End Sub

I remember that Visual Basic 6 allowed to enter Macro object from Microsoft Application. Now with Visual Basic 2008 Express Edition?

Foi útil?

Solução

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'Funziona  Estrapola in un file HTML
    'Dim settaggio As New XsltSettings
    'Dim xslt As New XslCompiledTransform
    'xslt.Load("Stile.xslt", settaggio, New XmlUrlResolver())
    'xslt.Transform("Fascicolo.xml", "Fascicolo.html")
    'Fine funziona

    ' Create the XslTransform object and load the style sheet. File XSLT
    Dim xslt As New XslCompiledTransform()
    xslt.Load(Label4.Text)
    ' Load the file to transform. File XML
    Dim doc As New Xml.XPath.XPathDocument(Label2.Text)
    ' Create the writer.
    Dim writer As XmlWriter = XmlWriter.Create(DirListBox3.Path & "\" & "Fascicolo.doc", xslt.OutputSettings)
    ' Transform the file and send the output to the console.
    xslt.Transform(doc, writer)
    writer.Close()

    Process.Start(DirListBox3.Path & "\" & "Fascicolo.doc")

    Dim var As New Microsoft.Office.Interop.Word.Application()
    Dim ciao As New Microsoft.Office.Interop.Word.Document
    ciao.Activate()


    var.Documents.Open(FileName:="C:\Users\f.irrera\Desktop\Fascicolo.doc")
    var.Selection.WholeStory()
    var.Selection.Copy()

    var.ChangeFileOpenDirectory("C:\Users\f.irrera\Desktop\")
    var.ActiveDocument.SaveAs2(FileName:="Fascicolo.daf", FileFormat:=2)

    ciao.Close()
    var.Documents.Close()
    var.Application.Quit()

End Sub
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top