ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
12
返回列表 发新帖
楼主: yi-kuai

[求助] [求助]行高的单位"磅"到底为多少?谢谢!急!

[复制链接]

TA的精华主题

TA的得分主题

发表于 2003-6-1 00:15 | 显示全部楼层
按厘米或英寸改变单元格的行高、列宽(微软) '一、按厘米改变 Sub RowHeightInCentimeters() Dim cm As Integer ' Get the row height in centimeters. cm = Application.InputBox("Enter Row Height in Centimeters", _ "Row Height (cm)", Type:=1) ' If cancel button not pressed and a value entered. If cm Then ' Convert and set the row height Selection.RowHeight = Application.CentimetersToPoints(cm) End If End Sub Sub ColumnWidthInCentimeters() Dim cm As Integer, points As Integer, savewidth As Integer Dim lowerwidth As Integer, upwidth As Integer, curwidth As Integer Dim Count As Integer ' Turn screen updating off. Application.ScreenUpdating = False ' Ask for the width in inches wanted. cm = Application.InputBox("Enter Column Width in Centimeters", _ "Column Width (cm)", Type:=1) ' If cancel button for the input box was pressed, exit procedure. If cm = False Then Exit Sub ' Convert the inches entered to points. points = Application.CentimetersToPoints(cm) ' Save the current column width setting. savewidth = ActiveCell.ColumnWidth ' Set the column width to the maximum allowed. ActiveCell.ColumnWidth = 255 ' If the points desired is greater than the points for 255 ' characters... If points > ActiveCell.Width Then ' Display a message box because the size specified is too ' large and give the maximum allowed value. MsgBox "Width of " & cm & " is too large." & Chr(10) & _ "The maximum value is " & _ Format(ActiveCell.Width / 28.3464566929134, _ "0.00"), vbOKOnly + vbExclamation, "Width Error" ' Reset the column width back to the original. ActiveCell.ColumnWidth = savewidth ' Exit the Sub. Exit Sub End If ' Set the lowerwidth and upper width variables. lowerwidth = 0 upwidth = 255 ' Set the column width to the middle of the allowed character ' range. ActiveCell.ColumnWidth = 127.5 curwidth = ActiveCell.ColumnWidth ' Set the count to 0 so if it can't find an exact match it won't ' go on indefinitely. Count = 0 ' Loop as long as the cell width in is different from width ' wanted and the count (iterations) of the loop is less than 20. While (ActiveCell.Width <> points) And (Count < 20) ' If active cell width is less than desired cell width. If ActiveCell.Width < points Then ' Reset lower width to current width. lowerwidth = curwidth ' set current column width to the midpoint of curwidth ' and upwidth. Selection.ColumnWidth = (curwidth + upwidth) / 2 ' If active cell width is greater than desired cell width. Else ' Set upwidth to the curwidth. upwidth = curwidth ' Set column width to the mid point of curwidth and lower ' width. Selection.ColumnWidth = (curwidth + lowerwidth) / 2 End If ' Set curwidth to the width of the column now. curwidth = ActiveCell.ColumnWidth ' Increment the count counter. Count = Count + 1 Wend End Sub ‘****************************************************************** '二、按英寸改变 Sub RowHeightInInches() Dim inches As Integer ' Get the desired column width. inches = Application.InputBox("Enter Row Height in Inches", _ "Row Height (Inches)", Type:=1) ' If the cancel button was not pressed. If inches Then ' Convert and set the column height. Selection.RowHeight = Application.InchesToPoints(inches) End If End Sub Sub ColumnWidthInInches() Dim inches As Integer, points As Integer, savewidth As Integer Dim lowerwidth As Integer, upwidth As Integer, curwidth As Integer Dim Count As Integer ' Turn screen updating off. Application.ScreenUpdating = False ' Ask for the desired width in inches. inches = Application.InputBox("Enter Column Width in Inches", _ "Column Width (Inches)", Type:=1) ' If the cancel button for the input box is pressed, exit the ' procedure. If inches = False Then Exit Sub ' Convert the entered inches to points. points = Application.InchesToPoints(inches) ' Save the current column width setting. savewidth = ActiveCell.ColumnWidth ' Set the column width to the maximum allowed. ActiveCell.ColumnWidth = 255 ' If points wanted is greater than points for 255 characters. If points > ActiveCell.Width Then ' Display a message box (the specified size is too large), and ' let user know maximum allowed value. MsgBox "Width of " & inches & " is too large." & Chr(10) & _ "The maximum value is " & Format(ActiveCell.Width / 72, _ "0.00"), vbOKOnly + vbExclamation, "Width Error" ' Reset the column width back to the original. ActiveCell.ColumnWidth = savewidth ' Exit out of the Sub from here. Exit Sub End If ' Set the lowerwidth and upperwidth variables. lowerwidth = 0 upwidth = 255 ' Set the column width to the middle of the allowed character range. ActiveCell.ColumnWidth = 127.5 curwidth = ActiveCell.ColumnWidth ' Set the count to 0 so if it can't find an exact match it won't go ' indefinitely. Count = 0 ' Loop as long as the cell width is different from width desired ' and the count (iterations) of the loop is less than 20. While (ActiveCell.Width <> points) And (Count < 20) ' If active cell width is less than desired cell width. If ActiveCell.Width < points Then ' Reset lower width to current width. lowerwidth = curwidth ' Set current column width to the midpoint of curwidth and ' upwidth. Selection.ColumnWidth = (curwidth + upwidth) / 2 ' If active cell width is greater than desired width. Else ' Set upwidth to the curwidth. upwidth = curwidth ' Set column width to the mid point of curwidth and lower ' width. Selection.ColumnWidth = (curwidth + lowerwidth) / 2 End If ' Set curwidth to the width of the column now. curwidth = ActiveCell.ColumnWidth ' Increment the count counter. Count = Count + 1 Wend End Sub

TA的精华主题

TA的得分主题

发表于 2009-5-2 18:59 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
原帖由 三戒 于 2008-8-21 11:56 发表
QUOTE:以下是引用xiaog在2003-6-1 0:15:00的发言:按厘米或英寸改变单元格的行高、列宽(微软)'一、按厘米改变Sub RowHeightInCentimeters()&#160;&#160;&#160;&#160;&#160;&#160; Dim cm As Integer&#160;&#160;&n ...

太好了,谢谢!
试了试,
小于1cm似乎不行!

[ 本帖最后由 csd3111 于 2009-5-2 19:06 编辑 ]

TA的精华主题

TA的得分主题

发表于 2011-6-21 17:27 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
这个似乎很有用,留个记号!

TA的精华主题

TA的得分主题

发表于 2011-12-29 17:16 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
这个似乎很有用,留个记号!

TA的精华主题

TA的得分主题

发表于 2012-1-14 00:34 | 显示全部楼层
什么时候仔细核对一下代码0~255,小于1cm确实不行

TA的精华主题

TA的得分主题

发表于 2014-6-20 12:29 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2024-7-27 18:38 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
jwb444 发表于 2007-2-19 01:49
请查看:jwb444“分享mm为单位的行高列宽(标尺)”的贴子72磅=1吋=25.4mm行高和列宽都有一个步进值(1像 ...

行高和列宽的单位具体是什么呢?如果直接读取xml文件里面的数据,如果将里面的行高和列宽计算为像素或者厘米?
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-10-23 18:36 , Processed in 0.029984 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表