检查range对象的ListFormat子对象的ListType属性,如: Select Case Selection.Range.ListFormat.ListType Case WdListType.wdListBullet MsgBox "Bullet" Case WdListType.wdListNoNumbering MsgBox "No numbering" case ... End Select
按楼上大哥的方法项目符号有无可以区分,其它符号和picture可以区分,剩下的"圆点"、"方点"、"菱形"等符号返回是一样的都是“bullet”,请帮我看看代码那里改一下,以下是我用vb写的代码: Dim wr As New Word.Application wr.Documents.Open (App.Path & "\WDA10_84.DOC") wr.Selection.WholeStory 'Debug.Print wr.Selection.Range.ListFormat. Select Case wr.Selection.Range.ListFormat.ListType Case WdListType.wdListBullet MsgBox "Bullet" Case WdListType.wdListNoNumbering MsgBox "No numbering" Case WdListType.wdListListNumOnly MsgBox "numonly" Case WdListType.wdListMixedNumbering MsgBox "mixednum" Case WdListType.wdListOutlineNumbering MsgBox "outline" Case WdListType.wdListPictureBullet MsgBox "picture" Case WdListType.wdListSimpleNumbering MsgBox "Simple" Case Else MsgBox "haha" End Select Dim a As String a = wr.Selection.Range.ListFormat.ListType Debug.Print a wr.Application.Quit Set wr = Nothing
上msdn站点查吧,基本都有例子的
看下面的例子 Dim i As Integer
Set objDoc = GetObject("c:\1.doc") objDoc.Activate '项目符号; For i = 1 To objDoc.Paragraphs.Count If objDoc.Paragraphs(i).Range.ListFormat.ListType <> 0 Then MsgBox "第" & i & " 段有项目符号" End If Next i
objDoc.Close Set objDoc = Nothing
... Case WdListType.wdListBullet Dim lngCodePoint As Long lngCodePoint = AscW(wr.selection.Range.ListFormat.ListTemplate.ListLevels(wr.selection.Range.ListFormat.ListLevelNumber).NumberFormat) And &HFFF Select Case lngCodePoint Case 183 MsgBox "圆点" Case 111 MsgBox "圆圈" Case 167 MsgBox "方块" Case Else MsgBox "字符unicode代码:" & CStr(lngCodePoint) End Select ...
Case WdListType.wdListBullet
MsgBox "Bullet"
Case WdListType.wdListNoNumbering
MsgBox "No numbering"
case ...
End Select
Dim wr As New Word.Application
wr.Documents.Open (App.Path & "\WDA10_84.DOC")
wr.Selection.WholeStory
'Debug.Print wr.Selection.Range.ListFormat.
Select Case wr.Selection.Range.ListFormat.ListType
Case WdListType.wdListBullet
MsgBox "Bullet"
Case WdListType.wdListNoNumbering
MsgBox "No numbering"
Case WdListType.wdListListNumOnly
MsgBox "numonly"
Case WdListType.wdListMixedNumbering
MsgBox "mixednum"
Case WdListType.wdListOutlineNumbering
MsgBox "outline"
Case WdListType.wdListPictureBullet
MsgBox "picture"
Case WdListType.wdListSimpleNumbering
MsgBox "Simple"
Case Else
MsgBox "haha"
End Select
Dim a As String
a = wr.Selection.Range.ListFormat.ListType
Debug.Print a
wr.Application.Quit
Set wr = Nothing
Set objDoc = GetObject("c:\1.doc")
objDoc.Activate '项目符号;
For i = 1 To objDoc.Paragraphs.Count
If objDoc.Paragraphs(i).Range.ListFormat.ListType <> 0 Then
MsgBox "第" & i & " 段有项目符号"
End If
Next i
objDoc.Close
Set objDoc = Nothing
Case WdListType.wdListBullet
Dim lngCodePoint As Long
lngCodePoint = AscW(wr.selection.Range.ListFormat.ListTemplate.ListLevels(wr.selection.Range.ListFormat.ListLevelNumber).NumberFormat) And &HFFF
Select Case lngCodePoint
Case 183
MsgBox "圆点"
Case 111
MsgBox "圆圈"
Case 167
MsgBox "方块"
Case Else
MsgBox "字符unicode代码:" & CStr(lngCodePoint)
End Select
...
不过我的机器上得到unicode值你上面演示的不同,“圆点”108 ,您上面是假定还是不同的word库有不同的数字?
1)Word菜单:格式->项目符号和编号-〉选中要查的项目符号
2)点“自定义”,然后点“字符”
我用VB才半年时间,以前用Intouch挺好用的(就是不太常见找不到工作),出意外丢了工作才开始用vb,vba刚开始学,上面的东西都是靠录制宏搞得到的,给你以假象,其实很菜。
大哥就送人送到家吧!(哈哈,有点得寸进尺!不过在学进度又有问题。有劳)
怎么能知道word 或 excel的那个range进行了合并单元格命令?
我在用select方法选择有合并动作的单元格时会报错,虽然错误处理勉强可以判断但肯定速度太慢!
望指教!
我是北京大兴人,大家交个朋友吧
[email protected]
qq33288179 不过忙得没时间上,哈哈