Upload af fil til FTP server vha makro
Hej eskperter!Denne makro har tidligere sendt en textfil til en filserver. Denne server er ikke tilgængelig længere. Derfor ønsker vi at sende den til en FTP server istedet. Kan I hjælpe med at redigere nedenstående makro, så vi blot senere hen skal udfylde brugernavn og password.
Private Sub CommandButton1_Click()
Dim FilId As String
Dim FilDato As String
Dim TidNu As Date
Dim TidTimer As String
Dim TidMinutter As String
Dim TidSekunder As String
For counter = 8 To 19
Cells(counter, 3) = Replace(Cells(counter, 3), Chr(10), " ")
Next
If Month(Date) < 10 Then
If Day(Date) < 10 Then
FilDato = Year(Date) & "0" & Month(Date) & "0" & Day(Date)
Else
FilDato = Year(Date) & "0" & Month(Date) & Day(Date)
End If
Else
If Day(Date) < 10 Then
FilDato = Year(Date) & Month(Date) & "0" & Day(Date)
Else
FilDato = Year(Date) & Month(Date) & Day(Date)
End If
End If
TidNu = Now
If Hour(TidNu) < 10 Then
TidTimer = "0" & Hour(TidNu)
Else
TidTimer = Hour(TidNu)
End If
If Minute(TidNu) < 10 Then
TidMinutter = "0" & Minute(TidNu)
Else
TidMinutter = Minute(TidNu)
End If
If Second(TidNu) < 10 Then
TidSekunder = "0" & Second(TidNu)
Else
TidSekunder = Second(TidNu)
End If
FilId = FilDato & " " & TidTimer & TidMinutter & TidSekunder & " " & Cells(10, 3)
FilId = "\\(tidligere filserver adresse)/" & FilId & " " & Cells(12, 3) & ".txt"
Close #1
Open FilId For Output As #1
txtOutput = ""
For counter = 8 To 19
If counter = 18 Then
If Month(Cells(counter, 3)) < 10 Then
If Day(Cells(counter, 3)) < 10 Then
txtOutput = txtOutput & """" & Year(Cells(counter, 3)) & "0" & Month(Cells(counter, 3)) & "0" & Day(Cells(counter, 3)) & """"
Else
txtOutput = txtOutput & """" & Year(Cells(counter, 3)) & "0" & Month(Cells(counter, 3)) & Day(Cells(counter, 3)) & """"
End If
Else
If Day(Cells(counter, 3)) < 10 Then
txtOutput = txtOutput & """" & Year(Cells(counter, 3)) & Month(Cells(counter, 3)) & "0" & Day(Cells(counter, 3)) & """"
Else
txtOutput = txtOutput & """" & Year(Cells(counter, 3)) & Month(Cells(counter, 3)) & Day(Cells(counter, 3)) & """"
End If
End If
Else
txtOutput = txtOutput & """" & CStr(Cells(counter, 3)) & """"
End If
If counter < 19 Then txtOutput = txtOutput & ","
Next
Print #1, txtOutput
txtOutput = ""
Close #1
MsgBox ("Jobbet er gemt")
End Sub
