简体   繁体   English

如何浏览/定位MS Word并使用vb.net显示它

[英]How to browse / locate MS Word and display it using vb.net

I try to follow this LINK but this tutorial is viewing direct an MS Word that has already an data to it. 我尝试遵循此LINK,但是本教程将直接查看已经有数据的MS Word。

I also try this code below 我也在下面尝试此代码

  Dim objWord As Word.Application
    Dim objDoc As Word.Document
    objWord = CreateObject("Word.Application")
    objDoc = objWord.Documents.Open("G:\Folder\NewFolder\HHHHH.docx")
    objWord.Visible = True

but this code is fix that if the MS Word it in that path and view it. 但是此代码是固定的,如果MS Word在该路径中并对其进行查看。

All I want to achieve is Browse the MS Word wherever it is located on my PC and display it in the form. 我要实现的是浏览MS Word,无论它在我的PC上位于何处,并以表格形式显示。 And if possible click a button and preview it in crystal report. 并尽可能单击一个按钮并在Crystal Report中预览它。 So I can print it. 这样我就可以打印了。

You can use OpenFileDialog: 您可以使用OpenFileDialog:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


    Dim filedialog As New OpenFileDialog

    filedialog.InitialDirectory = "C:\"
    filedialog.Filter = "Word Files|*.docx"
    filedialog.ShowDialog()

End Sub

works fine for me. 对我来说很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM