vbscript 选择陈述

=choose(Fields!Organisationlevel.Value, "Red", "Green", "Orange", "Blue")

if it is 1 then is red, if it is two then is green, if it is 3 is "orange", otherwise is blue
Video: Section 7, 56. Program Flow Functins

it can also be combined with iif

 choose(Fields!Organisationlevel.Value, "Red", "Green", "Orange"))

vbscript 带表达式的新数据集字段


Video: Section 5, 47. Expanding the chart

vbscript 工具提示表达

=Fields!Name.Value & " - " & Fields!CountOfProducts.Value & "products"

tooltip result: Road Bikes - 43 Products (example)

vbscript 计数


the number of elemnts not the sum of it, for example 10 products

vbscript 开关

=switch(Fields!ListPrice.Value<200, "Low",
        Fields!PriceList.Value<1000, "Medium",
        Fields!PriceList>=1000, "High")
if list price is smaller then 200 then is low, if price list is smaller then 1000 then is medium, if price list is bigger or equal 1000 then is high  

vbscript if else声明

if else statement
=iif(Fields!ListPrice.Value < 200, "Low", iif(Fields!ListPrice < 1000, "Medium", "High"))

if list price is smaller then 200 then is low, if list price is smaller then 1000 then is medium otherwise is high

vbscript 行bg颜色

row bg color
=iif(RowNumber("DataSet") Mod 2 = 0, "Yellow", "Transparent")

if rows from DataSet is dividable with 2 then should bg be yellow otherwise transparent

vbscript 嵌入图像

Sub MoveAndSizeWithCells() 
    Dim xPic As Picture 
    On Error Resume Next 
    Application.ScreenUpdating = False 
    For Each xPic In ActiveSheet.Pictures 
        xPic.Placement = xlMoveAndSize 
    Application.ScreenUpdating = True 
End Sub

vbscript 从所有文档中删除分隔页


Public Sub SeparatorPageDelete(ByVal pXRootFolder As CASCADELib.CscXFolder)
   On Error GoTo ErrorHandler
   OutputDebugString "Scansation.SeparatorPageDelete"

   Dim i As Long
   Dim oXdoc As CscXDocument
   Dim lPageIndex As Long

   If Project.ScriptVariables.ItemByName("SeparatorPageDelete").Value = "True" Then
      OutputDebugString "Scansation.Separator page removal enabled, deleting seperator pages..."

      ' Here, we're assuming that the separator page is the last page of the document having been moved to the end during KTM Server Batch_Open

      For i = 0 To pXRootFolder.DocInfos.Count - 1
         OutputDebugString "Scansation.Document: " & CStr(i=1)
         Set oXdoc = pXRootFolder.DocInfos.ItemByIndex(i).XDocument

         ' Double check the page contains the separation barcode before deleting it
         If oXdoc.Fields.ItemByName("SepPageBarcode1").PageIndex = oXdoc.CDoc.Pages.Count - 1 Then
            lPageIndex = oXdoc.CDoc.Pages.Count - 1
            oXdoc.DeletePages(lPageIndex, 1)
         End If


   End If

Exit Sub
   LogError(Err.Number, "SeparatorPageDelete", Err.Description)
End Sub

vbscript dynamicMenu - getContent

Office XML_33
Office VBA_35
Sub CallbackGetContent(control As IRibbonControl, ByRef XMLString)
    Dim lngDummy    As Long
    Dim strDummy    As String
    Dim strContent  As String
    strDummy = "<menu xmlns=""http://schemas.microsoft"
    strDummy = strDummy & ".com/office/2006/01/customui"">"
        For lngDummy = 0 To 5
            strContent = strContent & _
            "<button id=""MyDynaButton" & lngDummy & _
            """ label =""Dynamic Item" & _
            lngDummy & """/>"
    strDummy = strDummy & strContent & " </menu>"
    XMLString = strDummy
End Sub