编写文件夹路径

时间:2016-12-11 10:24:39

标签: vb.net

Private Sub Createbutton_Click(sender As Object, e As EventArgs) Handles Create.Click

    Dim MyPassword As String = "Password"
    Dim oItem As Object
    Dim OffS As Integer
    Dim MsExcel As Excel.Application
    Dim Wb As Excel.Workbook

    MsExcel = CreateObject("Excel.Application")
    'ASPTS is my project name and Default is a folder i created 
    Wb = MsExcel.Workbooks.Add("..\\ASPTS\ASPTS\Default\football.xlsm")
    OffS = 0
    For Each oItem In TeamListBox.Items
        Wb.Sheets(1).Range("A2").Offset(OffS, 0).Value = oItem
        OffS = OffS + 1
    Next oItem

    FSaveFileDialog.Filter = "Excel Files (*.xlsm)|*.xslsm"
    Wb.SaveAs(Filename:="..\\ASPTS\ASPTS\Football\" & TextBox1.Text & ".xlsm", FileFormat:=52, Password:=MyPassword,
    WriteResPassword:=MyPassword, ReadOnlyRecommended:=False, CreateBackup:=False)

    Wb.Close()

End Sub

如果我改变这样的路径 (" C:\ Users \用户名\桌面\ ASPTS \ ASPTS \默认\ football.xlsm&#34) 它工作正常,但我不想在文件夹路径中指定任何驱动器,因为我的项目应该能够在其他驱动器和其他驱动器中运行。

0 个答案:

没有答案