word的vba, 要怎麼改轉到excel後的字型及格式
- 帖子
- 128
- 主題
- 13
- 精華
- 1
- 積分
- 118
- 點名
- 0
- 作業系統
- WinXP
- 軟體版本
- Office2003
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 四川成都邛崃
- 註冊時間
- 2010-9-13
- 最後登錄
- 2017-5-12
|
和在Excel里是一样的:
Sub test()
Dim xlWkApp As Object, xlWk As Object
Set xlWkApp = CreateObject("excel.application")
With xlWkApp
.Visible = True
With .Workbooks.Add.Sheets(1)
With .Range("a1")
.Value = ThisDocument.Tables(2).Cell(2, 6)
.Font.ColorIndex = 3
.HorizontalAlignment = 3
End With
.Range("a2") = ThisDocument.Tables(2).Cell(5, 6)
.Range("a1:a2").Borders.LineStyle = 1
End With
End With
End Sub |
|
|
|
|
|
|
|
- 帖子
- 128
- 主題
- 13
- 精華
- 1
- 積分
- 118
- 點名
- 0
- 作業系統
- WinXP
- 軟體版本
- Office2003
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 四川成都邛崃
- 註冊時間
- 2010-9-13
- 最後登錄
- 2017-5-12
|
我的版本是Office2003,word表格里的内容输入到excel后,包含了一些非打印字符.我上次删的那个贴子对此进行了处理.
Function myCell(s)
Dim tmp
tmp = Replace(s, Chr(13), "")
tmp = Replace(tmp, Chr(7), "")
tmp = Replace(tmp, Chr(32), "")
myCell = tmp
End Function
Sub test()
Dim xlWkApp As Object, xlWk As Object
Set xlWkApp = CreateObject("excel.application")
With xlWkApp
.Visible = True
With .Workbooks.Add.Sheets(1)
With .Range("a1")
.Value = myCell(ThisDocument.Tables(2).Cell(2, 6))
.Font.ColorIndex = 3
.HorizontalAlignment = 3
End With
.Range("a2") = myCell(ThisDocument.Tables(2).Cell(5, 6))
.Range("a1:a2").Borders.LineStyle = 1
End With
End With
End Sub |
|
|
|
|
|
|
|