我在excel中使用以下代码,以便可以在受保护的工作表中用+和-勾勒轮廓。
现在,我还想格式化这些被保护工作表中的列(和/或单元格)。这可能吗?
亲切的问候, 里科
Private Sub Workbook_Open()
For Each Sheet In Worksheets
Sheet.Unprotect Password:="riccowendy"
Sheet.EnableOutlining = True
Sheet.Protect Password:="riccowendy", UserInterfaceOnly:=True
Next
End Sub
答案 0 :(得分:0)
尝试以下子项。
Sub DoOutline()
For Each sht In Worksheets
sht.Unprotect Password:="riccowendy"
sht.Cells.Borders(xlDiagonalDown).LineStyle = xlNone
sht.Cells.Borders(xlDiagonalUp).LineStyle = xlNone
With sht.Cells.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With sht.Cells.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With sht.Cells.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With sht.Cells.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With sht.Cells.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With sht.Cells.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
sht.Protect Password:="riccowendy", UserInterfaceOnly:=True
Next
End Sub
答案 1 :(得分:0)
Google“受保护工作表上的vba excel更改格式”确实帮助了这一问题:
docs.microsoft.com ... allowformattingcells
#!/bin/bash
# Script to convert output of accel-cmd to JSON format
# Author: lfelipe
# Since: 2019-02-12
# Return of accel-cmd
ACCEL_RETURN=$(accel-cmd show sessions username,ifname,calling-sid,rate-limit,state | grep -v 'calling-sid' | grep -v '+-----' | sed 's/ //g')
# To save JSON format in string
JSON="["
# Delimiter of for
OLD_IFS=$IFS
IFS=$'\n'
# For each result
for USER in $ACCEL_RETURN
do
USERNAME=`echo ${USER} | cut -d '|' -f 1`
IFNAME=`echo ${USER} | cut -d '|' -f 2`
SID=`echo ${USER} | cut -d '|' -f 3`
RATE=`echo ${USER} | cut -d '|' -f 4`
JSON+='{'
JSON+='"username":"'${USERNAME}'",'
JSON+='"data":{'
JSON+='"ifname":"'${IFNAME}'",'
JSON+='"calling-sid":"'${SID}'",'
JSON+='"rate-limit":"'${RATE}'"'
JSON+='}'
JSON+='},'
done
# Default delimiter
IFS=$OLD_IFS
JSON+="]"
#Remove the last comma
JSON=`echo ${JSON%,*} ${JSON##*,}`
# Print JSON in string
echo "$JSON"
exit