Hello,
I have a macro which is correct work on a desktop.
When I try work on it on teams/SharePoint/one drive I get an error
How i can change this code on worked on web ?
Code
Dim strEmail As String Dim rngZakres As Range Dim wksBaza As Worksheet Dim csvFile As String Dim OutApp As Object Dim OutMail As Object
Set wksBaza = Worksheets("Baza")
'kolejne przekszta?cenia, by otrzyma? widoczny zakres danych
Set rngZakres = wksBaza.AutoFilter.Range
With rngZakres 'bez nag?ówka Set rngZakres = .Offset(1).Resize(.Rows.Count - 1) End With
Set rngZakres = rngZakres.SpecialCells(xlCellTypeVisible) 'widoczne wiersze
'pe?na ?cie?ka do pliku te kstowego csvFile = ThisWorkbook.Path & "\" & "Baza" & Format(Now(), "dd-mm-yyyyhhnnss") & ".txt"
Call SaveRange2Txt(rngZakres, Array(1, 28, 29, 30), csvFile)
'Email
Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0)
With OutMail .To = "email" 'ustaw odbiorce .CC = " " .BCC = "" .Subject = "txt" .Body = "Plik txt" .Attachments.Add csvFile
.Display '<-- wy?wietl ' lub '.Send '<-- wy?lij End With
Set OutMail = Nothing Set OutApp = Nothing
'Usun po wyslaniu ' Kill csvFiles(1)
With wksBaza .Select .Range("A6").Select End With Application.CutCopyMode = False
End Sub
Sub SaveRange2Txt(rng As Range, cols, strFilename As String)
'cols - tablica numerów kolumn do pozostwienia (numery wzgl?dne)
'z przekazanego zakresu komórek tworzy plik tekstowy z separatorami ";" Dim iFn As Integer Dim strOutput As String Dim csvFile As String Dim rngRow As Range Dim vTmp As Variant
For Each rngRow In rng.Rows vTmp = Application.Index(rngRow.Value, cols)
strOutput = strOutput & vbCr & Join(vTmp, ";")
Next rngRow
strOutput = Mid(strOutput, 2)
iFn = FreeFile
'Zamienia tre?? pliku (je?li wcze?niej istnia?) na strOutput Open strFilename For Output Access Write As #iFn
Print #iFn, strOutput
Close #iFn
End Sub
Display More