我正在使用在Windows XP上運行但未安裝Office或.NET Framework的計算機。 我想通過打開FileDialog
來打開/保存文件。不幸的是,他們沒有列出(在VBA編輯器中)作爲一個類。我如何將它們放入我的代碼中?如何在沒有引用的情況下在vba中打開FileDialog(打開/保存)
下面是我用來保存(它工作,但我真的需要filedialogs)的例子。我以同樣的方式實現打開文件:
Sub Make_File()
Dim i As Long
Dim AnzTrace As Long
Dim SysAbstand As Double
Dim DatName, Type, Dummy As String
Dim SysDist As Double
Dim Nr, Pos, Offset, Phase As Double
Dim SysDate, SysTime As String
Dim Buff1, Buff2, Buff3 As String
Dim Day, Time As Variant
Dim AktDir As String
AktDir = CurDir
Call Shell("C:\WINDOWS\explorer " & AktDir, 1) ' I need to change folder in file explorer in order to save the file where i want...
Message1 = "Dateinamen eingeben (ohne .txt)"
Title = "Data Input"
Default1 = TXTDatName
DatName = InputBox(Message1, Title, Default1)
If DatName = "" Then
GoTo ExitMakeFile
End If
Message1 = "Kommentar eingeben"
Title = "Data Input"
Default1 = "bla bla bla"
Type = InputBox(Message1, Title, Default1)
If Type = "" Then
GoTo ExitMakeFile
End If
Message1 = "Systemabstand eingeben"
Title = "Data Input"
Default1 = "116"
SysDist = InputBox(Message1, Title, Default1)
If Dummy = Null Then
GoTo ExitMakeFile
End If
Day = SCPI.SYSTem.Date
Buff1 = Format(Day(0), "####")
Buff2 = Format(Day(1), "0#")
Buff3 = Format(Day(2), "0#")
SysDate = Buff1 & "/" & Buff2 & "/" & Buff3
Time = SCPI.SYSTem.Time
Buff1 = Format(Time(0), "0#")
Buff2 = Format(Time(1), "0#")
SysTime = Buff1 & ":" & Buff2
AnzTrace = SCPI.CALCulate(1).PARameter.Count
Dummy = " "
DatName = AktDir & "\" & DatName & ".txt"
i = AnzTrace
Open DatName For Output As #1
Print #1, AntennaType
Print #1, "Datum: " & SysDate & " " & SysTime
Buff1 = "X" & Chr(9) & "Abstand" & Chr(9) & "Kabel" & Chr(9) & "gedreht"
Print #1, Buff1
Print #1, Dummy
Do While i > 1
Pos = SysDist
Offset = 0
Phase = 0
Buff3 = Str(i) & Chr(9) & Str(Pos) & Chr(9) & Str(Offset) & Chr(9) & Str(Phase)
Print #1, Buff3
i = i - 1
Loop
Buff3 = Str(i) & Chr(9) & " 0" & Chr(9) & Str(Offset) & Chr(9) & Str(Phase)
Print #1, Buff3
Close #1
Call Shell("C:\WINDOWS\notepad " & DatName, 1)
ExitMakeFile:
End Sub
的http://支持.microsoft.com/kb/161286 – dee
如果沒有Office,什麼主機VB你正在使用的環境? –
你在哪裏使用VBA? –