PPT上“单击此处添加文本,插入表格,插入图表,插入SmartArt图形,插入来自文件的图片,插入

2007以上版本,PPT上版式框里“单击此处添加文本,插入表格,插入图表,插入SmartArt图形,插入来自文件的图片,插入剪贴画,插入媒体剪辑”的效果怎么在excel的单元格里做出来?即,举个简单例子就是插入图片,点击单元格,可以选择文件夹、文件,选定图片后,图片插入到单元格内,大小与单元格一致。

Excel本身没这个功能,只能用VBA来做程序.单元格也无图片填充功能,图片永远都浮在单元格的上面.

子易空间站 - Excel培训专家追问

上面下面无所谓,只要这个单元格点了能选图片,选了能出来,出来了图片大小跟单元格一样就可以了。

追答

在工作表模块插入下面的代码:
点A4单元格,就可以选择并插入图片.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("a4").Address Then
Dim pf As FileDialog
Dim fn As String
Dim p As Shape

Set pf = Application.FileDialog(msoFileDialogOpen)
pf.Show
If pf.SelectedItems.Count > 0 Then
fn = pf.SelectedItems(1)
Set p = Target.Worksheet.Shapes.AddPicture(fn, msoFalse, msoCTrue, Target.Left, Target.Top, Target.Width, Target.Height)
p.Placement = xlMoveAndSize
End If
Set p = Nothing
Set pf = Nothing
End If
End Sub

子易空间站 - Excel培训专家

追问

开了个新表格试了一下,确实有用。如果要换格子,是不是只用把"a4"改成别的就行?如果是合并单元格有效吗?

追答

要对合并的有用:改一下

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("a4").Address Or (Target.MergeCells And Target.Cells(1).Address = Range("a4").Address) Then
Dim pf As FileDialog
Dim fn As String
Dim p As Shape

Set pf = Application.FileDialog(msoFileDialogOpen)
pf.Show
If pf.SelectedItems.Count > 0 Then
fn = pf.SelectedItems(1)
Set p = Target.Worksheet.Shapes.AddPicture(fn, msoFalse, msoCTrue, Target.Left, Target.Top, Target.Width, Target.Height)
p.Placement = xlMoveAndSize
End If
Set p = Nothing
Set pf = Nothing
End If
End Sub

追问

嗯嗯,很有效~最后一个追问:我同时有好几个合并单元格,都需要做成这种可选的,怎么做的?

追答

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ta As String

If Target.MergeCells Then
ta = Target.Cells(1).Address(0, 0)
Else
ta = Target.Address(0, 0)
End If

Select Case LCase(ta)
Case "a4", "b5", "c6" '修改此处单元格
Dim pf As FileDialog
Dim fn As String
Dim p As Shape

Set pf = Application.FileDialog(msoFileDialogOpen)
pf.Show
If pf.SelectedItems.Count > 0 Then
fn = pf.SelectedItems(1)
Set p = Target.Worksheet.Shapes.AddPicture(fn, msoFalse, msoCTrue, Target.Left, Target.Top, Target.Width, Target.Height)
p.Placement = xlMoveAndSize
End If
Set p = Nothing
Set pf = Nothing
End Select

End Sub

子易空间站 - Excel培训专家

那改成这样吧~

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-27
幻灯片里面有个母版,在视图里面,在这里可以给幻灯片的背景图上加LOG之类的设计图,具体你可以百度下幻灯片母版制作追问

和PPT没关系,举个例子而已,我要解决的是EXCEL里的问题

相似回答