如何用VB调整Excel中的图形大小,使得它的大小为100%,即图形的原始大小?

liutiejiang 2006-08-13 01:25:32
我用vb操纵Excel,利用AddPicture函数向excel中插入图片,由于图片大小不一致,因此,图片大小的参数无法精确给出,但是,我想通过vb指令,使得插入的图片能够是100%的?如何解决呢?请教!
我的方法如下:
Dim shapeCode As Excel.Shape
Set shapeCode = tt.Shapes.AddPicture(temp_finger.bmp", True, True, tt.Cells(1, 1).Left, tt.Cells(1,1).Top, 100,100)
注:100,100是随意写的,我想在这句话之后,再通过某种方法,使得插入的图片大小变成100%原始大小的?该如何做呢?
...全文
890 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hassle 2006-09-30
  • 打赏
  • 举报
回复
Option Explicit

Private Type BITMAP '14 bytes
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type

Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

Private Sub Command1_Click()
Dim MyPicture As StdPicture
Dim udtBM As BITMAP
Dim oApp As Excel.Application
Dim oBok As Excel.Workbook
Dim oSht As Excel.Worksheet
Dim oShp As Excel.Shape

Set MyPicture = LoadPicture("C:\Test.bmp")
GetObject MyPicture.Handle, LenB(udtBM), udtBM
Set MyPicture = Nothing

Set oApp = New Excel.Application
oApp.Visible = True
Set oBok = oApp.Workbooks.Add
Set oSht = oBok.Worksheets(1)

Set oShp = oSht.Shapes.AddPicture("temp_finger.bmp", msoFalse, msoTrue, oSht.Cells(1, 1).Left, oSht.Cells(1, 1).Top, udtBM.bmWidth, udtBM.bmHeight)
End Sub
zqsntws 2006-09-30
  • 打赏
  • 举报
回复
up
panq19a 2006-09-10
  • 打赏
  • 举报
回复
up

2,503

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧