本文介绍了将宏Word 2010插入Visual Basic 2008 Express Edition中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Microsoft Word 2010创建了一个宏:
I created a Macro with Microsoft Word 2010:
Sub Macro1()
Selection.WholeStory
End Sub
在Button1_Click事件发生时,我将执行宏:
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
我记得Visual Basic 6允许从Microsoft应用程序输入Macro对象.现在有了Visual Basic 2008 Express Edition吗?
I remember that Visual Basic 6 allowed to enter Macro object from Microsoft Application.Now with Visual Basic 2008 Express Edition?
推荐答案
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
这篇关于将宏Word 2010插入Visual Basic 2008 Express Edition中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!