首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

代码不明吧,请高手们讲解下···()

2012-03-21 
代码不明吧,请高手们讲解下(在线等)请高手忙吧讲解下谢谢!!With ActiveSheetIf Target.Count 2 Then Exi

代码不明吧,请高手们讲解下···(在线等)
请高手忙吧讲解下···谢谢!!
With ActiveSheet
If Target.Count > 2 Then Exit Sub

Set rng = .Range("E28")
If Union(rng, Target).Address = rng.Address Then
  Static chkrange As Range
  If Not chkrange Is Nothing Then
  chkrange.Comment.Delete
  End If
   
  Dim cmt As Comment
  Dim hasComment As Comment
  Dim jpgImg As Object
   
  Set chkrange = Target
  Set hasComment = Target.Comment
   
  If hasComment Is Nothing Then
  Set cmt = Target.AddComment
  Else
  Set cmt = Target.Comment
  End If
  cmt.Visible = True
   
  pcode = .[b28].Text
   
  If VBA.Asc(pcode) >= 65 And VBA.Asc(pcode) <= 122 Then
  ac = VBA.Left(pcode, 7)
  If InStr(1, ac, "-") > 0 Then
  fname = "V:\P Code\Customer\" & .[E38].Text & "\" & pcode & ".jpg"
  Else
  fname = "V:\P Code\Others\AC Code\" & pcode & ".jpg"
  End If
   
  Else
  str = VBA.Left(pcode, 6)
  If CInt(str) <= 1000 Then
  fname = sPath & "000001-001000\" & pcode & ".jpg"
  ElseIf CInt(str) > 1000 And CInt(str) <= 2000 Then
  fname = sPath & "001001-002000\" & pcode & ".jpg"
  ElseIf CInt(str) > 2000 And CInt(str) <= 3000 Then
  fname = sPath & "002001-003000\" & pcode & ".jpg"
  ElseIf CInt(str) > 3000 And CInt(str) <= 4000 Then
  fname = sPath & "003001-004000\" & pcode & ".jpg"
  ElseIf CInt(str) > 4000 And CInt(str) <= 5000 Then
  fname = sPath & "004001-005000\" & pcode & ".jpg"
  ElseIf CInt(str) > 5000 And CInt(str) <= 6000 Then
  fname = sPath & "005001-006000\" & pcode & ".jpg"
  ElseIf CInt(str) > 6000 And CInt(str) <= 7000 Then
  fname = sPath & "006001-007000\" & pcode & ".jpg"
  ElseIf CInt(str) > 7000 And CInt(str) <= 8000 Then
  fname = sPath & "007001-008000\" & pcode & ".jpg"
  ElseIf CInt(str) > 8000 And CInt(str) <= 9000 Then
  fname = sPath & "008001-009000\" & pcode & ".jpg"
  ElseIf CInt(str) > 9000 And CInt(str) <= 10000 Then
  fname = sPath & "009001-010000\" & pcode & ".jpg"
  ElseIf CInt(str) > 10000 And CInt(str) <= 11000 Then
  fname = sPath & "010001-011000\" & pcode & ".jpg"
  End If
  End If
   
  Set jpgImg = CreateObject("WIA.ImageFile")
  jpgImg.LoadFile fname
  iw = jpgImg.Width
  ih = jpgImg.Height
  cmt.Shape.Fill.UserPicture fname
  cmt.Shape.Line.ForeColor.SchemeColor = 9
  cmt.Shape.ZOrder msoSendToBack
  cmt.Shape.LockAspectRatio = msoFalse
   
  nh = .Range("D29:E36").Height


  nw = .Range("D29:E36").Width
   
  Set rg = .Range("D29:E36")

[解决办法]
在E28中输入一个数值,从文件夹中找到对应的图片,插入到批注里面来。

热点排行