请问以下这段excel中的 VBA 如何及其改动后能 直接 在 VB6 中用?
谢谢了!由于版面过大,特用两个帖子贴出来。Sub a()
Range("B2:H17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
谢谢了!由于版面过大,特用两个帖子贴出来。Sub a()
Range("B2:H17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
解决方案 »
- 怎么才知道该text1中的内容在txt文本中的行数(哪行)? VB代码
- VBScript中如何访问ie缓存中的文件呢
- 请大侠帮忙看看以下DLL 函数
- 如何使用VB编写一个FTP传输程序
- 关于系统托盘鼠标右键的问题
- 100分关于图片预览
- 怎么样能禁止改变窗体大小,但最小话和还原按钮还能使用?
- 如何让水晶报表显示程序中根据SQL动态查询的数据
- @@@@@@@@各位大虾求求你父救我了WINSOCK的地址族不支持问题不知如何解决@@@@@@@@@@@
- 和DBF库之间的一点妖怪问题,帮忙看看,跪求答案
- 求教 :总是报错 453:找不到DLL入口点 ShellL_NotifyIconA in shell32.dll
- 怎么样取得EXCEL文件的WorkSheet中最后一个没有内容的行和列它们分别的名称?
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("B2:H3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
Application.Left = 90.25
Application.Top = 153.25
Range("B4:H4").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
Application.Left = 142
Application.Top = 3.25
Range("B11:H11").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
Range("B2:H3").Select
ActiveCell.FormulaR1C1 = "fxbb"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B4:H4").Select
ActiveCell.FormulaR1C1 = "nb"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B5").Select
ActiveCell.FormulaR1C1 = "xm"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B6").Select
ActiveCell.FormulaR1C1 = "zc"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B7").Select
ActiveCell.FormulaR1C1 = "fsd"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B8").Select
ActiveCell.FormulaR1C1 = "srl"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveCell.FormulaR1C1 = "jkd"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B10").Select
ActiveCell.FormulaR1C1 = "jkg"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("C5").Select
ActiveCell.FormulaR1C1 = "ndjh"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("D5").Select
ActiveCell.FormulaR1C1 = "jdjh"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("E5").Select
ActiveCell.FormulaR1C1 = "drwc"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("F5").Select
ActiveCell.FormulaR1C1 = "ljwc"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("G5").Select
ActiveCell.FormulaR1C1 = "ljcq"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveCell.FormulaR1C1 = "rjsxwc"
With ActiveCell.Characters(Start:=1, Length:=6).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B11:H11").Select
ActiveCell.FormulaR1C1 = "yb"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B12").Select
ActiveCell.FormulaR1C1 = "xm"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B13").Select
ActiveCell.FormulaR1C1 = "zc"
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B14").Select
ActiveCell.FormulaR1C1 = "fsd"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B15").Select
ActiveCell.FormulaR1C1 = "srl"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B16").Select
ActiveCell.FormulaR1C1 = "jkd"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B17").Select
ActiveCell.FormulaR1C1 = "jkg"
With ActiveCell.Characters(Start:=1, Length:=3).Font
.Name = "Times New Roman"
.FontStyle = "常规"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
然后在公共模块定义一个全局变量
Public exl As Excel.Application
需要使用EXCEL的地方添加如下代码
Set exl = GetObject(, "Excel.Application") '查找一个正在运行的Excel拷贝
If Err.Number <> 0 Then '如果 Excel 没有运行则
Set exl = CreateObject("Excel.Application") '运行它
End If
Err.Clear '清除发生错误的 Err 对象
On Error GoTo 0 '保留普通错误进程最后把你的那堆代码贴到后面即可
能告述我你的email吗?
:)
希望多多向大哥请教了!