Adding an object - macro
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Adding an object - macro

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi,

    Can anyone help me? I want to have my users click a command button to open a dialogue to browse for a photo and add it to a field in a worksheet.

    Please...

  2. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-04-17 06:55, Matty2470 wrote:
    Hi,

    Can anyone help me? I want to have my users click a command button to open a dialogue to browse for a photo and add it to a field in a worksheet.

    Please...
    Try;


    'This routine will prompt you for the file location
    'Then ask you for the Top cell location to paste to.

    Sub Insert_Pict()
    Dim Pict
    Dim ImgFileFormat As String
    Dim PictCell As Range
    Dim Ans As Integer

    'ActiveSheet.Protect True, True, True, True, True
    ImgFileFormat = "Image Files wmf (*.gif),*.gif,(*.bmp),others , jpg (*.jpg),*.jpg"

    GetPict:
    Pict = Application.GetOpenFilename(ImgFileFormat)
    'Note you can load in nearly file format
    If Pict = False Then End

    Ans = MsgBox("Open : " & Pict, vbYesNo, "Insert Picture")
    If Ans = vbNo Then GoTo GetPict

    'Now paste to userselected cell
    GetCell:
    Set PictCell = Application.InputBox("Select the cell to insert into", Type:=8)
    If PictCell.Count > 1 Then MsgBox "Select ONE cell only": GoTo GetCell

    PictCell.Select
    'PictCell.Activate
    ActiveSheet.Pictures.Insert(Pict).Select


    End Sub


    'to delete ALL picture files then;

    Sub DeletePicts()
    Dim Pict As Object

    For Each Pict In ActiveSheet.Shapes
    MsgBox "This is " & Pict.Name & ": Type:= " & Pict.Type
    If Pict.Type = 13 Then
    Pict.Delete
    End If
    Next

    End Sub






    Kind Regards,
    Ivan F Moala From the City of Sails

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com