< návrat zpět
MS Excel
Téma: Export CSV
Zaslal/a Tomas 9.8.2011 10:29
Zdravim,
umel byste nekdo do nasledujiciho kodu pridat nejake vyskakujici okno, ktere by se zeptalo na nazev souboru, ktery chci ulozit?
Predem moc dekuji.
Sub EXPORTjournal()
Application.DisplayAlerts = False
Set myRng = ActiveWindow.RangeSelection
Set newbook = Workbooks.Add
With newbook
.Title = "export"
.SaveAs Filename:="C:\Documents and Settings\tdvorak\Desktop\Journals\WF Journals\export.csv", FileFormat:=xlCSV
End With
myRng.Copy
Windows("export.csv").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Workbooks("export.csv").Save
Workbooks("export.csv").Close
Application.DisplayAlerts = True
MsgBox ("Journal successfully exported.csv")
End Sub
RomanNTA(10.8.2011 9:02)#005756 Sub EXPORTjournal()
Dim s As String
s = InputBox("Něco", "Něco jiného", "export.csv")
If StrComp(s, "") = 0 Then Exit Sub
Application.DisplayAlerts = False
Set myRng = ActiveWindow.RangeSelection
Set newbook = Workbooks.Add
With newbook
.Title = "export"
.SaveAs FileName:="C:\Documents and Settings\tdvorak\Desktop\Journals\WF Journals\" & s, FileFormat:=xlCSV
End With
myRng.Copy
Windows(s).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Workbooks(s).Save
Workbooks(s).Close
Application.DisplayAlerts = True
MsgBox ("Journal successfully " & s)
End Sub
Je to napsané od ruky ... když tak si to dolaď. R.
citovat
Tomas(11.8.2011 11:42)#005775 Zdravim,
kousne se to u:
Windows(s).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Workbooks(s).Save
Workbooks(s).Close
Application.DisplayAlerts = True
MsgBox ("Journal successfully " & s)
End Sub
Nemelo by tam byt misto toho "s" neco jineho? "s" je pro cely inputbox, nebo pro nasledne vlozenou hodnotu?
Diky
citovat
Tomas(12.8.2011 10:29)#005781 Tak jeste zmena, funguje to pro soubory ulozene jako *.xls, ale pro novy format *.xlsx to ji nefunguje.
Lze jeste nejak kod upravit, aby fungoval i pro nove *.xlsx soubory?
Dekuji.
citovat