Code: Select all
function fnWhichComponent(oDoc) as string
if HasUnoInterfaces(oDoc, "com.sun.star.lang.XServiceInfo") then
if thisComponent.supportsService ("com.sun.star.text.GenericTextDocument") then
fnWhichComponent = "Text"
elseif thisComponent.supportsService("com.sun.star.sheet.SpreadsheetDocument") then
fnWhichComponent = "Spreadsheet"
elseif thisComponent.supportsService("com.sun.star.presentation.PresentationDocument") then
fnWhichComponent = "Presentation"
elseif thisComponent.supportsService("com.sun.star.drawing.GenericDrawingDocument") then
fnWhichComponent = "Drawing"
else
fnWhichComponent = "Oops current document something else"
end if
else
fnWhichComponent = "Not a document"
end if
End function
Function Replace(Source As String, Search As String, NewPart As String)
Dim Result As String
Result = join(split(Source, Search), NewPart)
Replace = Result
End Function
'oSheet.getCellRangeByName("A11")
'oView.Select(oCell)
SUB STARTUP
On Error GoTo UNKNOWNERROR
Dim check as string
dim tcheck as string
dim document as object
dim dispatcher as object
oDoc = ThisComponent
oView = oDoc.getCurrentController()
oSheet = odoc.getSheets().getByIndex(0)
document = oView.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
if fnWhichComponent(thisComponent) <> "Spreadsheet" then
exit sub
end if
wait 600
oCell = ThisComponent.getSheets().getByIndex(0).getCellRangeByName("ZZ1")
check = oCell.getstring
oCell = ThisComponent.getSheets().getByIndex(0).getCellRangeByName("H11")
tcheck = oCell.getstring
oCell = ThisComponent.getSheets().getByIndex(0).getCellRangeByName("H59")
Ocheck = oCell.getstring
'PRINT oCheck
if oCheck = "TOTAL ESTIMATE PRICE" then
SETUPDOC
END IF
If check = 5615 then
ret& = Msgbox ("Please make sure to double check your work. Thank you", 10 + 1, "Reminder")
dim args14(2) as new com.sun.star.beans.PropertyValue
args14(0).Name = "Zoom.Value"
args14(0).Value = 100
args14(1).Name = "Zoom.ValueSet"
args14(1).Value = 28703
args14(2).Name = "Zoom.Type"
args14(2).Value = 0
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args14())
oCell = oSheet.getCellRangeByName("J1")
oView.select(oCell)
else
if tcheck = "TOTAL ESTIMATE PRICE" then
'ret& = Msgbox ("ESTIMATE PAGE DETECTED", 10 + 1, "INFORMATION")
dim args15(2) as new com.sun.star.beans.PropertyValue
args15(0).Name = "Zoom.Value"
args15(0).Value = 100
args15(1).Name = "Zoom.ValueSet"
args15(1).Value = 28703
args15(2).Name = "Zoom.Type"
args15(2).Value = 0
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args15())
oCell = oSheet.getCellRangeByName("J1")
oView.select(oCell)
PREP
end if
end if
EXIT SUB
UNKNOWNERROR:
ret& = Msgbox ("Please make sure to double check your work. Thank you", 10 + 1, "Error")
Exit Sub
END SUB
Sub SaveAs1
'On Error GoTo UNKNOWNERROR
if fnWhichComponent(thisComponent) <> "Spreadsheet" then
exit sub
end if
Dim Check as string
Dim tCheck as string
dim Document as object
dim Dispatcher as object
Dim MyFilename as string
dim MyPath as string
Dim Url as string
dim Url1 as string
DIM PAGE AS STRING
oDoc = ThisComponent
oView = oDoc.getCurrentController()
oSheet = odoc.getSheets().getByIndex(0)
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
document = ThisComponent.CurrentController.Frame
oCell = oSheet.getCellRangeByName("ZZ2")
CHECK = oCell.getstring
oCell = oSheet.getCellRangeByName("H11")
tcheck = oCell.getstring
If check = 5615 then
oCell = oSheet.getCellRangeByName("U2")
myFilename = oCell.getstring
myfilename = Replace(myfilename, "/", " ")
myfilename = replace(myfilename, "\", " ")
oCell = oSheet.getCellRangeByName("C15")
Cname = oCell.getstring
Cname = replace(Cname, "/", " ")
Cname = replace(Cname, "\", " ")
ocell.setstring(Cname)
IF MyFilename = " " and tCheck = "TOTAL ESTIMATE PRICE" then
dim args16(2) as new com.sun.star.beans.PropertyValue
args16(0).Name = "Zoom.Value"
args16(0).Value = 100
args16(1).Name = "Zoom.ValueSet"
args16(1).Value = 28703
args16(2).Name = "Zoom.Type"
args16(2).Value = 0
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args16())
oCell = oSheet.getCellRangeByName("J1")
oView.select(oCell)
PREP
EXIT SUB
END IF
oCell = oSheet.getCellRangeByName("U4")
MyPath = "C:\Users\main\Documents\EST PDF\"
'MyPath = oCell.getstring
url = ConvertToUrl(MyPath & MyFilename & ".ods")
url1= ConvertToUrl(MyPath & MyFilename & ".pdf")
'ret& = Msgbox ("Files saved to folder " & MyPath & " with a filenames of " & MyFilename & " .ods and " & MyFilename & " .pdf", 10 + 1, "Information")
'PRINT MYPATH
'PRINT MYFILENAME
'PRINT URL
oDoc.StoreAsUrl(url,Array())
dim args12(1) as new com.sun.star.beans.PropertyValue
dim Arg(0) as new com.sun.star.beans.PropertyValue
oCell = oSheet.getCellRangeByName("W47")
page = oCell.getstring
IF PAGE = 1 THEN
Arg(0).Name = "PageRange"
Arg(0).Value = "1"
args12(1).Name = "FilterData"
args12(1).Value = Arg()
goto pdf
END IF
IF PAGE = 2 THEN
Arg(0).Name = "PageRange"
Arg(0).Value = "1,2"
args12(1).Name = "FilterData"
args12(1).Value = Arg()
goto pdf
END IF
IF PAGE = 3 THEN
Arg(0).Name = "PageRange"
Arg(0).Value = "1,2,3"
args12(1).Name = "FilterData"
args12(1).Value = Arg()
goto pdf
END IF
IF PAGE = 4 THEN
Arg(0).Name = "PageRange"
Arg(0).Value = "1,2,3,4"
args12(1).Name = "FilterData"
args12(1).Value = Arg()
goto pdf
END IF
IF PAGE = 5 THEN
Arg(0).Name = "PageRange"
Arg(0).Value = "1,2,3,4,5"
args12(1).Name = "FilterData"
args12(1).Value = Arg()
goto pdf
END IF
IF PAGE = 6 THEN
Arg(0).Name = "PageRange"
Arg(0).Value = "1,2,3,4,5,6"
args12(1).Name = "FilterData"
args12(1).Value = Arg()
goto pdf
END IF
PDF:
args12(0).Name = "FilterName"
args12(0).Value = "calc_pdf_Export"
oDoc.storeToURL(url1,args12())
ret& = Msgbox ("Files saved to folder " & MyPath & " with a filenames of " & MyFilename & " .ods and " & MyFilename & " .pdf", 10 + 1, "Information")
EXIT SUB
end if
UNKNOWNERROR:
ret& = Msgbox ("Unknown error, Auto save macro is disabled, and you will be prompted to save", 10 + 1, "ERROR")
End Sub
sub pageprint
On Error GoTo UNKNOWNERROR
dim document as object
dim dispatcher as object
Dim oSheet : oSheet = oDoc.Sheets.getByIndex(0)
Dim oReturn : oReturn = oDoc.Sheets.getByIndex(0)
DIM PCHECK AS STRING
Dim Page as string
oDoc = ThisComponent
oView = oDoc.getCurrentController()
oSheet = odoc.getSheets().getByIndex(0)
oCell = oSheet.getCellRangeByName("ZZ3")
Pcheck = oCell.getstring
If Pcheck <> 5615 then
exit sub
end if
oCell = oSheet.getCellRangeByName("W47")
page = oCell.getstring
IF PAGE = 1 OR PAGE > 1 THEN
oSheet = oDoc.Sheets.getByIndex(0)
oView.setActiveSheet(oSheet)
oDoc.Print(Array())
Wait 50
END IF
IF PAGE = 2 OR PAGE > 2 THEN
oSheet = oDoc.Sheets.getByIndex(1)
oView.setActiveSheet(oSheet)
oDoc.Print(Array())
Wait 50
END IF
IF PAGE = 3 OR PAGE > 3 THEN
oSheet = oDoc.Sheets.getByIndex(2)
oView.setActiveSheet(oSheet)
oDoc.Print(Array())
Wait 50
END IF
IF PAGE = 4 OR PAGE > 4 THEN
oSheet = oDoc.Sheets.getByIndex(3)
OVIEW.setActiveSheet(oSheet)
ODOC.Print(Array())
Wait 50
END IF
IF PAGE = 5 OR PAGE > 5 THEN
oSheet = oDoc.Sheets.getByIndex(4)
oView.setActiveSheet(oSheet)
oDoc.Print(Array())
Wait 50
END IF
IF PAGE = 6 OR PAGE > 6 THEN
oSheet = oDoc.Sheets.getByIndex(5)
oView.setActiveSheet(oSheet)
oDoc.Print(Array())
Wait 50
END IF
oView.setActiveSheet(oReturn)
EXIT SUB
UNKNOWNERROR:
ret& = Msgbox ("Unknown error, Print page macro is disabled", 10 + 1, "ERROR")
End Sub
sub PREP
dim document as object
dim dispatcher as object
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDoc = ThisComponent
oView = oDoc.getCurrentController()
document = oView.Frame
unprotectall
oSheet = odoc.getSheets().getByIndex(0)
'oView.Select(oCell)
oCell = oSheet.getCellRangeByName("u1")
oCell.setstring("FILENAME")
oCell = oSheet.getCellRangeByName("u2")
oCell.setformula("=CONCATENATE($Q$16;"+CHR$(34)+" "+CHR$(34)+";$C$15;"+CHR$(34)+" "+CHR$(34)+";$Q$18)")
oCell = oSheet.getCellRangeByName("ZZ1")
oCell.setstring("5615")
oCell = oSheet.getCellRangeByName("ZZ2")
oCell.setstring("5615")
oCell = oSheet.getCellRangeByName("ZZ3")
oCell.setstring("5615")
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=$PAGE_6.$W$47+$PAGE_5.$W$47+$PAGE_4.$W$47+$PAGE_3.$W$47+$PAGE_2.$W$47+1")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
oSheet = odoc.getSheets().getByIndex(1)
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=IF($V$47>0;1;0)")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
oSheet = odoc.getSheets().getByIndex(2)
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=IF($V$47>0;1;0)")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
oSheet = odoc.getSheets().getByIndex(2)
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=IF($V$47>0;1;0)")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
oSheet = odoc.getSheets().getByIndex(3)
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=IF($V$47>0;1;0)")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
oSheet = odoc.getSheets().getByIndex(4)
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=IF($V$47>0;1;0)")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
oSheet = odoc.getSheets().getByIndex(5)
oCell = oSheet.getCellRangeByName("W47")
oCell.setformula("=IF($V$47>0;1;0)")
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
protectall
'dim args10(0) as new com.sun.star.beans.PropertyValue
'args10(0).Name = "ToPoint"
'args10(0).Value = "$H$11"
'dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args10())
oSheet = odoc.getSheets().getByIndex(0)
ocell = oSheet.getCellRangeByName("H11")
oView.Select(oCell)
'saveas1
'odoc.close(true)
end sub
SUB COPY
DIM CHECK, C, CELL, OCELL, OCHECK
Dim oDoc, oSheet, NoArg()
DIM oSRangeA1, oSRangeA2, oSRangeA3, oSRangeA4, oSRangeA5, oSRangeA6, oSRangeB1, oSRangeB2, oSRangeB3, oSRangeB4, oSRangeB5, oSRangeB6, oSRangeC1, oSRangeC2, oSRangeC3, oSRangeC4, oSRangeC5, oSRangeC6, oSRangeD1, oSRangeD2, oSRangeD3, oSRangeD4, oSRangeD5, oSRangeD6, oSRangeE1, oSRangeE2, oSRangeE3, oSRangeE4, oSRangeE5, oSRangeE6, oSRangeF1, oSRangeF2, oSRangeF3, oSRangeF4, oSRangeF5, oSRangeF6
Dim oCell1, oCell2, oCell3, oCell4, oCell5, oCell6
Dim oTsheet1, oTsheet2, oTsheet3, oTsheet4, oTsheet5, oTsheet6, oSsheet
Dim Dispatcher, octl, oFrame
Dim oSourceDoc, oSourceSheet, oSourceRange
Dim oTargetDoc, oTargetSheet, oTargetCell
Dim sUrl As String
oDoc = ThisComponent
oView = oDoc.getCurrentController()
oFrame = oView.getFrame()
oTSheet1 = odoc.getSheets().getByIndex(0)
oTSheet2 = odoc.getSheets().getByIndex(1)
oTSheet3 = odoc.getSheets().getByIndex(2)
oTSheet4 = odoc.getSheets().getByIndex(3)
oTSheet5 = odoc.getSheets().getByIndex(4)
oTSheet6 = odoc.getSheets().getByIndex(5)
oSSheet = odoc.getSheets().getByIndex(6)
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
oSRangeA1 = oSsheet.getCellRangeByName("B15:R19")
oSRangeA2 = oSsheet.getCellRangeByName("B21:J32")
oSRangeA3 = oSsheet.getCellRangeByName("M21:O32")
oSRangeA4 = oSsheet.getCellRangeByName("R21:T32")
oSRangeA5 = oSsheet.getCellRangeByName("F40:R40")
oSRangeA6 = oSsheet.getCellRangeByName("V40:V46")
oSRangeB1 = oSsheet.getCellRangeByName("B69:J80")
oSRangeB2 = oSsheet.getCellRangeByName("M69:O80")
oSRangeB3 = oSsheet.getCellRangeByName("R69:T80")
oSRangeB4 = oSsheet.getCellRangeByName("F88:R88")
oSRangeB5 = oSsheet.getCellRangeByName("V88:V94")
oSRangeC1 = oSsheet.getCellRangeByName("B117:J128")
oSRangeC2 = oSsheet.getCellRangeByName("M117:O128")
oSRangeC3 = oSsheet.getCellRangeByName("R117:T128")
oSRangeC4 = oSsheet.getCellRangeByName("F136:R136")
oSRangeC5 = oSsheet.getCellRangeByName("V136:V142")
oSRangeD1 = oSsheet.getCellRangeByName("B165:J176")
oSRangeD2 = oSsheet.getCellRangeByName("M165:O176")
oSRangeD3 = oSsheet.getCellRangeByName("R165:T176")
oSRangeD4 = oSsheet.getCellRangeByName("F184:R184")
oSRangeD5 = oSsheet.getCellRangeByName("V184:V190")
oSRangeE1 = oSsheet.getCellRangeByName("B213:J224")
oSRangeE2 = oSsheet.getCellRangeByName("M213:O224")
oSRangeE3 = oSsheet.getCellRangeByName("R213:T224")
oSRangeE4 = oSsheet.getCellRangeByName("F232:R232")
oSRangeE5 = oSsheet.getCellRangeByName("V232:V238")
oSRangeF1 = oSsheet.getCellRangeByName("B261:J272")
oSRangeF2 = oSsheet.getCellRangeByName("M261:O272")
oSRangeF3 = oSsheet.getCellRangeByName("R261:T272")
oSRangeF4 = oSsheet.getCellRangeByName("F280:R280")
oSRangeF5 = oSsheet.getCellRangeByName("V280:V286")
oTcellA1 = oTSheet1.getCellRangeByName("B15")
oTcellA2 = oTSheet1.getCellRangeByName("B21")
oTcellA3 = oTSheet1.getCellRangeByName("M21")
oTcellA4 = oTSheet1.getCellRangeByName("R21")
oTcellA5 = oTSheet1.getCellRangeByName("F40")
oTcellA6 = oTSheet1.getCellRangeByName("V40")
oTcellB1 = oTSheet2.getCellRangeByName("B21")
oTcellB2 = oTSheet2.getCellRangeByName("M21")
oTcellB3 = oTSheet2.getCellRangeByName("R21")
oTcellB4 = oTSheet2.getCellRangeByName("F40")
oTcellB5 = oTSheet2.getCellRangeByName("V40")
oTcellC1 = oTSheet3.getCellRangeByName("B21")
oTcellC2 = oTSheet3.getCellRangeByName("M21")
oTcellC3 = oTSheet3.getCellRangeByName("R21")
oTcellC4 = oTSheet3.getCellRangeByName("F40")
oTcellC5 = oTSheet3.getCellRangeByName("V40")
oTcellD1 = oTSheet4.getCellRangeByName("B21")
oTcellD2 = oTSheet4.getCellRangeByName("M21")
oTcellD3 = oTSheet4.getCellRangeByName("R21")
oTcellD4 = oTSheet4.getCellRangeByName("F40")
oTcellD5 = oTSheet4.getCellRangeByName("V40")
oTcellE1 = oTSheet5.getCellRangeByName("B21")
oTcellE2 = oTSheet5.getCellRangeByName("M21")
oTcellE3 = oTSheet5.getCellRangeByName("R21")
oTcellE4 = oTSheet5.getCellRangeByName("F40")
oTcellE5 = oTSheet5.getCellRangeByName("V40")
oTcellF1 = oTSheet6.getCellRangeByName("B21")
oTcellF2 = oTSheet6.getCellRangeByName("M21")
oTcellF3 = oTSheet6.getCellRangeByName("R21")
oTcellF4 = oTSheet6.getCellRangeByName("F40")
oTcellF5 = oTSheet6.getCellRangeByName("V40")
oView.Select(oSRangeA1)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg()) 'copy
oView.Select(oTCellA1)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeA2)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellA2)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeA3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellA3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeA3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellA3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeA5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellA5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeA5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellA5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeB1)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellB1)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeB2)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellB2)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeB3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellB3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeB4)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellB4)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeB5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellB5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeC1)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellC1)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeC2)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellC2)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeC3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellC3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeC4)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellC4)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeC5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellC5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeD1)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellD1)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeD2)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellD2)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeD3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellD3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeD4)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellD4)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeD5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellD5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeE1)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellE1)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeE2)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellE2)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeE3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellE3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeE4)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellE4)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeE5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellE5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeF1)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellF1)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeF2)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellF2)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeF3)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellF3)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeF4)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellF4)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
oView.Select(oSRangeF5)
oDisp.executeDispatch(oView, ".uno:Copy", "", 0, NoArg())
oView.Select(oTCellF5)
oDisp.executeDispatch(oFrame, ".uno:Paste", "", 0, NoArg())
dim args100(0) as new com.sun.star.beans.PropertyValue
args100(0).Name = "Flags"
args100(0).Value = "SVDFN"
oView.Select(oSRangeA1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100()) 'copy
oView.Select(oSRangeA2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeA3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeA3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeA5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeA5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeB1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeB2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeB3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeB4)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeB5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeC1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeC2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeC3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeC4)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeC5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeD1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeD2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeD3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeD4)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeD5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeE1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeE2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeE3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeE4)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeE5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeF1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeF2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeF3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeF4)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(oSRangeF5)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oCell = OSSHEET.getCellRangeByName("H13")
check = oCell.getstring
ocell = ThisComponent.getSheets.getByIndex(0).getCellRangeByName("A11")
ThisComponent.getCurrentController().Select(oCell)
END SUB
sub setupdoc
ON ERROR RESUME NEXT
ret& = Msgbox ("Please don't click or type any thing, Setting up document", 10 + 1, "Please wait")
thisComponent.unprotect("")
ThisComponent.getSheets().getByIndex(0).unProtect("password")
ThisComponent.getSheets().getByIndex(0).unProtect("")
DIM DOC1, DOC2
Dim oDoc, oSheet, oRange
Dim oTDoc, oTSheet, oTCell
Dim oDisp, octl
Dim sUrl As String
Dim NoArg(),odel1,odel2,odel3
Dim oTsheet1, oTsheet2, oTsheet3, oTsheet4, oTsheet5, oTsheet6, oSsheet
oDoc = ThisComponent
oView = oDoc.getCurrentController()
oFrame = oView.getFrame()
oDoc=ThisComponent
octl = odoc.getCurrentController()
oframe = octl.getFrame()
OSHEET = ODOC.getSheets.getByIndex(0)
oSheets= oDoc.Sheets(0)
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
dim args100(0) as new com.sun.star.beans.PropertyValue
args100(0).Name = "Flags"
args100(0).Value = "SVDFN"
oDEL1 = oSheet.getCellRangeByName("ZZ1")
oDEL2 = oSheet.getCellRangeByName("ZZ2")
oDEL3 = oSheet.getCellRangeByName("ZZ3")
oView.Select(ODEL1)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100()) 'copy
oView.Select(ODEL2)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oView.Select(ODEL3)
oDisp.executeDispatch(oView, ".uno:Delete", "", 0, args100())
oRange = oSheets.getCellRangeByPosition(0,0,21,300)
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
octl.Select(oRange)
oDisp.executeDispatch(octl, ".uno:Copy", "", 0, NoArg())
sURL = ConvertToUrl("C:\Users\main\Documents\ESTIMATE.ots")
doc1 = ThisComponent.CurrentController.Frame.ContainerWindow
oTDoc = Stardesktop.loadComponentFromURL(sURL, "_blank", 0, NoArg())
addsheet
oTSheet = oTDoc.getSheets.getByIndex(6)
oTCell = oTSheet.getCellByPosition(0,0)
doc2 = ThisComponent.CurrentController.Frame.ContainerWindow
oTDoc.getCurrentController().Select(oTCell)
oTframe = oTDoc.getCurrentController().getFrame()
oDisp.executeDispatch(oTFrame, ".uno:Paste", "", 0, NoArg())
UNPROTECTALL
oCell = oTsheet.getCellRangeByName("S44")
oCell.setformula("=F44+G44+J44+L44+N44+P44+R44")
oCell = oTsheet.getCellRangeByName("S45")
oCell.setformula("=F45+G45+J45+L45+N45+P45+R45")
oCell = oTsheet.getCellRangeByName("S92")
oCell.setformula("=F92+G92+J92+L92+N92+P92+R92")
oCell = oTsheet.getCellRangeByName("S93")
oCell.setformula("=F93+G93+J93+L93+N93+P93+R93")
oCell = oTsheet.getCellRangeByName("S140")
oCell.setformula("=F140+G140+J140+L140+N140+P140+R140")
oCell = oTsheet.getCellRangeByName("S141")
oCell.setformula("=F141+G141+J141+L141+N141+P141+R141")
oCell = oTsheet.getCellRangeByName("S188")
oCell.setformula("=F188+G188+J188+L188+N188+P188+R188")
oCell = oTsheet.getCellRangeByName("S189")
oCell.setformula("=F189+G189+J189+L189+N189+P189+R189")
oCell = oTsheet.getCellRangeByName("S236")
oCell.setformula("=F236+G236+J236+L236+N236+P236+R236")
oCell = oTsheet.getCellRangeByName("S237")
oCell.setformula("=F237+G237+J237+L237+N237+P237+R237")
oCell = oTsheet.getCellRangeByName("S284")
oCell.setformula("=F284+G284+J284+L284+N284+P284+R284")
oCell = oTsheet.getCellRangeByName("S285")
oCell.setformula("=F285+G285+J285+L285+N285+P285+R285")
COPY
DELSHEET
PROTECTALL
PROTECT
PREP
SAVEAS1
ocell = ThisComponent.getSheets.getByIndex(0).getCellRangeByName("A11")
ThisComponent.getCurrentController().Select(oCell)
doc1.tofront()
doc1.setfocus()
DOC1.CLOSE
'DOC2.TOFRONT()
'DOC2.SETFOCUS()
End Sub
sub delSheet
ThisComponent.getSheets().removeByName("source")
End Sub
Sub addSheet
If ThisComponent.Sheets().hasByName("source") Then
'Msgbox "A sheet named: """ & sSheetName & """ already exists!"
Else
If ThisComponent.Sheets().getCount() > 255 Then
'Msgbox "Maximum number of sheets reached - cannot insert!"
Else
' insert as index 0 = first sheet in file
ThisComponent.Sheets().insertNewByName("source", 6 )
End If
End If
End Sub
SUB PROTECTALL
ThisComponent.getSheets().getByIndex(0).Protect("")
ThisComponent.getSheets().getByIndex(1).Protect("")
ThisComponent.getSheets().getByIndex(2).Protect("")
ThisComponent.getSheets().getByIndex(3).Protect("")
ThisComponent.getSheets().getByIndex(4).Protect("")
ThisComponent.getSheets().getByIndex(5).Protect("")
ThisComponent.protect("")
END SUB
SUB UNPROTECTALL
ON ERROR RESUME NEXT
ThisComponent.unprotect("")
ThisComponent.getSheets().getByIndex(0).unprotect("password")
ThisComponent.getSheets().getByIndex(0).unprotect("")
ThisComponent.getSheets().getByIndex(1).unprotect("password")
ThisComponent.getSheets().getByIndex(1).unprotect("")
ThisComponent.getSheets().getByIndex(2).unprotect("password")
ThisComponent.getSheets().getByIndex(2).unprotect("")
ThisComponent.getSheets().getByIndex(3).unprotect("password")
ThisComponent.getSheets().getByIndex(3).unprotect("")
ThisComponent.getSheets().getByIndex(4).unprotect("password")
ThisComponent.getSheets().getByIndex(4).unprotect("")
ThisComponent.getSheets().getByIndex(5).unprotect("password")
ThisComponent.getSheets().getByIndex(5).unprotect("")
end sub