Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default size FaceID picture on commandbutton

It is easy with Stephen Bullen's routine PastePicture to get an Office
FaceID on a CommandButton, but how do you set the size of picture?
..Picture.Height and .Width are read-only.
Any suggestions?

RBS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default size FaceID picture on commandbutton


Listed for your ref.
"Code by www.VBA.com.tw"
(Put into Mudule one)
Dim FolderName As String

Sub LoadPictures()
Dim k As Integer, r As Integer
Dim sExt As String
k = 1
r = 1
Application.ScreenUpdating = False
Del_msoPicture 'Pls clear of all pic in any worksheet
GetFolder
With Application.FileSearch
.NewSearch
.LookIn = FolderName
.SearchSubFolders = False
.Filename = "*.*"
.FileType = msoFileTypeAllFiles 'Search file types I
.Execute() 0 Then
For i = 1 To .FoundFiles.Count
sExt = UCase(Right(.FoundFiles(i), 3))
'Get Roo
name
If sExt = "JPG" Or sExt = "GIF" Then
'Merge jpg o
gif file
Set rng = Cells(r, k).Resize(5, 3)
Set Pic
ActiveSheet.Pictures.Insert(.FoundFiles(i)) 'Setup pic
'pic situation
With Pic
.Top = rng.Cells(1).Top
.Left = rng.Cells(1, 1).Left
.Height = rng.Height
.Width = rng.Width
End With
k = k + 4
Columns(k - 1).Interior.ColorIndex = 34
Columns(k - 1).ColumnWidth = 2
If k = 17 Then
r = r + 6
k = 1
Rows(r - 1).Interior.ColorIndex = 34
Rows(r - 1).RowHeight = 8
End If
End If
Next i
Else
MsgBox "No any pic"
End If
End With
Application.ScreenUpdating = True
End Sub

--------------------------------------------------------------------------------

Sub GetFolder() '取得資料夾
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
If fd.Show = -1 Then
FolderName = fd.SelectedItems(1)
Else
End
End If
End Sub

--------------------------------------------------------------------------------

Sub Del_msoPicture()
'刪除工作表圖片
'Const msoPicture = 13
On Error Resume Next
'預防工作表中無圖片
Cells.Interior.ColorIndex = xlNone
'清除儲存格背景色
Dim aryGroup() As String, i As Integer
Dim Sh As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = 13 Then 'msoPicture 類型
ReDim Preserve aryGroup(i)
aryGroup(i) = shp.Name
i = i + 1
End If
Next shp
ActiveSheet.DrawingObjects(aryGroup).Delete
On Error GoTo 0
End Su

--
00700700
-----------------------------------------------------------------------
007007007's Profile: http://www.excelforum.com/member.php...fo&userid=2911
View this thread: http://www.excelforum.com/showthread.php?threadid=49890

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default size FaceID picture on commandbutton

Before I give this a try, would this work with a button on a userform?

RBS

"007007007" wrote
in message ...

Listed for your ref.
"Code by www.VBA.com.tw"
(Put into Mudule one)
Dim FolderName As String

Sub LoadPictures()
Dim k As Integer, r As Integer
Dim sExt As String
k = 1
r = 1
Application.ScreenUpdating = False
Del_msoPicture 'Pls clear of all pic in any worksheet
GetFolder
With Application.FileSearch
NewSearch
LookIn = FolderName
SearchSubFolders = False
Filename = "*.*"
FileType = msoFileTypeAllFiles 'Search file types If
Execute() 0 Then
For i = 1 To .FoundFiles.Count
sExt = UCase(Right(.FoundFiles(i), 3))
'Get Root
name
If sExt = "JPG" Or sExt = "GIF" Then
'Merge jpg or
gif file
Set rng = Cells(r, k).Resize(5, 3)
Set Pic =
ActiveSheet.Pictures.Insert(.FoundFiles(i)) 'Setup pic
'pic situation
With Pic
Top = rng.Cells(1).Top
Left = rng.Cells(1, 1).Left
Height = rng.Height
Width = rng.Width
End With
k = k + 4
Columns(k - 1).Interior.ColorIndex = 34
Columns(k - 1).ColumnWidth = 2
If k = 17 Then
r = r + 6
k = 1
Rows(r - 1).Interior.ColorIndex = 34
Rows(r - 1).RowHeight = 8
End If
End If
Next i
Else
MsgBox "No any pic"
End If
End With
Application.ScreenUpdating = True
End Sub

--------------------------------------------------------------------------------

Sub GetFolder() '取得資料夾
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
If fd.Show = -1 Then
FolderName = fd.SelectedItems(1)
Else
End
End If
End Sub

--------------------------------------------------------------------------------

Sub Del_msoPicture()
'刪除工作表圖片
'Const msoPicture = 13
On Error Resume Next
'預防工作表中無圖片
Cells.Interior.ColorIndex = xlNone
'清除儲存格背景色
Dim aryGroup() As String, i As Integer
Dim Sh As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = 13 Then 'msoPicture 類型
ReDim Preserve aryGroup(i)
aryGroup(i) = shp.Name
i = i + 1
End If
Next shp
ActiveSheet.DrawingObjects(aryGroup).Delete
On Error GoTo 0
End Sub


--
007007007
------------------------------------------------------------------------
007007007's Profile:
http://www.excelforum.com/member.php...o&userid=29111
View this thread: http://www.excelforum.com/showthread...hreadid=498901


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change CommandButton Picture TheVisionThing Excel Programming 0 December 14th 05 05:24 PM
Displaying a picture by pushing CommandButton Jean[_4_] Excel Programming 4 February 14th 05 11:39 AM
jpeg picture always the same size Denny Excel Worksheet Functions 0 November 10th 04 04:00 AM
copy charts & paste as picture, hide chart, size & place same picture as chart Gunnar Johansson Excel Programming 0 October 30th 04 01:22 AM
Picture the same size as a cell Nater[_2_] Excel Programming 2 August 11th 04 06:52 PM


All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"