我想用浏览按钮打开一个excel模板,该文件需要打开,必须由用户直接保存。保存文件后,文件位置需要显示在文本框中。
有了这个,我可以打开excel本身,但我不知道如何打开模板并保存文件
Dim Xl As Excel.Application
Dim Filepath As String
Dim Workbook As Excel.Workbook
Dim Worksheet1 As Excel.Worksheet
Dim Worksheet2 As Excel.Worksheet
Private Sub BrowseExcelfilenaam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrowseExcelfilenaam.Click
Xl = CreateObject("Excel.Application")
Xl.Workbooks.Open("location\Geluidscherm_template.xls")
Xl.Visible = True
ExcelFilepath = Xl.GetSaveAsFilename(FileFilter:="Excel Files (*.xls), *.xls")
Excelfilenaam.Text = (ExcelFilepath)
End Sub
文件打开,我得到一个另存为对话框,但是当我想要保存文件时,它没有保存;但是它不会给我一个错误。
答案 0 :(得分:0)
Dim objApp As New Excel.Application
Dim objWorkbook As Excel.Workbook = objApp.Workbooks.Open(FilePath)
objApp.Visible = True