Na tym forum znalazłem makro, które kopiuje wybrany arkusz do nowego pliku.
W arkuszu mam pare guzików, formuł itd.
W jaki sposób można zmienić makro aby kopiowało mi arkusz ale bez tych wszystkich przycisków itd ?
Chodzi mi o to aby skopiować to tak jak wygląda dokument na podglądzie czyli tak jak się drukuje.
Kod: Zaznacz cały
' Katalog bazowy dokumentów
Const csBaseDocDir As String = "c:\Dowody"
Const csSheetName As String = "Faktura"
Const csNumberFormat As String = "000000"
Private sPathSep As String
' ========================================================
' SaveSheet
' ========================================================
Sub SaveSheet
Dim oDoc As Object
Dim oSheet As Object
Dim oCell As Object
Dim dDate As Date
Dim sDocNumber As String
Dim sDateISO As String
Dim sDirDay As String
Dim sDirMonth As String
Dim sDirYear As String
Dim sDir As String
sPathSep = GetPathSeparator()
oDoc = ThisComponent
oSheet = oDoc.Sheets.getByName(csSheetName)
oCell = oSheet.getCellByPosition(10,1) ' B3 Data dok.
dDate = oCell.getValue()
oCell = oSheet.getCellByPosition(15,2) ' F8 Numer dok.
sDocNumber = oCell.getString() ' wartosc jako tekst
' sDocNumber = Format(oCell.getValue(), csNumberFormat) ' wartosc z formatowaniem
sDateISO = CDateToISO(dDate)
sDirDay = Right(sDateISO,2)
sDirMonth = Mid(sDateISO, 5, 2)
sDirYear = Left(sDateISO, 4)
sDir = csBaseDocDir + sPathSep + sDirYear + _
sPathSep + sDirMonth
SaveDocument sDir, sDocNumber + ".ods"
End Sub
' ========================================================
' SaveDocument
' ========================================================
Sub SaveDocument( sDirName As String, sFileName As String )
Dim args(0) As New com.sun.star.beans.PropertyValue
Dim sURL As String
MkDir(sDirName)
sURL=ConvertToURL(sDirName + sPathSep + sFileName)
ThisComponent.storeToURL(sURL, args())
End Sub