VB 6.0 - Insert Picture in a specific cell of an excel using vb6
Asked By Jan S
08-Feb-10 01:10 AM
Hi,
I need to insert a picture from a local path into a specific cell (For e.g. "A2") in an excel?
can anybody tell me how to proceed with this?
Thanks
Jan
Ryan C. replied to Jan S
Try this:
Private Sub CommandButton4_Click()
Dim PicLocation As String
Dim MyRange As String
ActiveSheet.Unprotect
Range("A9").Select
MyRange = Selection.Address
PicLocation = Application.GetSaveAsFilename("C:\", "Image Files (*.jpg),*.jpg", , "Specify Image Location")
If PicLocation <> "False" Then
ActiveSheet.Pictures.Insert(PicLocation).Select
Else
Exit Sub
End If
With Selection.ShapeRange
.LockAspectRatio = msoTrue
If .Width > .Height Then
.Width = Range(MyRange).Width
If .Height > Range(MyRange).Height Then .Height = Range(MyRange).Height
Else
.Height = Range(MyRange).Height
If .Width > Range(MyRange).Width Then .Width = Range(MyRange).Width
End If
End With
With Selection
.Placement = xlMoveAndSize
.PrintObject = True
End With
Range("H16").Select
ActiveSheet.Protect
End Sub
You could use code snippet like this:-
| oExcel = Createobject('Excel.Application') |
| With oExcel |
| .WorkBooks.Add |
| .Visible = .T. |
| |
| With .ActiveWorkBook.ActiveSheet |
| Local loRange |
| loRange = .Range('B2:E6') |
| |
| .Shapes.AddPicture( _samples+'data\graphics\buchstev.gif', .T., .T., ; |
| loRange.Left, loRange.Top, loRange.Width, loRange.Height) |
| Endwith |
Endwith (Refer http://social.msdn.microsoft.com/forums/en-US/visualfoxprogeneral/thread/78f86ad4-2da7-410b-9290-b61cdd2d069c/) |
This would need the "Excel Interop" to be added as reference into your application.

VB 6.0 , Insert Image into database Hi All, I am trying to save image into Access table, Table structure is • Emp_no Numeric • Emp_name Character • Photo Ole Object How to insert image. . . . ? Ex. form has 3 tools xemp_no, xemp_name, picture1 cmd.text = "insert into emp_master(emp_no, emp_name, photo) values(" & xemp_no & ", '" & xemp_name & "', '" & picture1.picture & "')" cmd.execute It gives error Regards. Check this link - http: / / vb-helper.com / howto_store_image_in_access_db.html Hi MV, Thanks for your reply, but my problem is I GetTemporaryDirectory() & TEMPIMAGEFILENAME) 'update the record set cmdLogo.Tag = GetTemporaryDirectory() & TEMPIMAGEFILENAME 'Below is a MOD. . Please Insert the below code in a module Option Explicit Const BLOCK_SIZE = 16384 Sub BlobToFile(fld As
VB 6.0 SETUP HELP hi all, i m trying to make vb 6.0 application setup. in that setup what i want any user who install my application will serial no. please help me To restrict No of installations on same pc : You can insert blank form for taking input for no of instances. on same pc, just link the modify the value in registry during installation process check this thread: http: / / www.bigresource.com / VB-Change-registry-during-installation- -Kc6FdvLoEw.html#lusAl5Hjl5 My problem is still NOT resolved Create New
Doubt in v.b 6.0 Hi all, I, m new to vb.6.0 and i don, t know how to connect to sql server through v.b 6.0 with the help of adodc control, and anyone plz tell me how connect and insert , update, delete and other functions, coz i tried in m.s access not in sqlserver
Syntax for connecting VB 6.0 to MS ACCESS Hi, I Am new to VB 6.0 and need to connect it to MS ACCESS.Can anyone help me with the syntax tell what it means??I need it urgently Just add the MDAC reference in your vb 6.0 application. http: / / www.eggheadcafe.com / articles / 20010822.asp end of post In your project
BUILD A Visual Studio .NET C# MS Search Webservice with VB 6.0 COM Interop BUILD A Visual Studio .NET C# MS Search Webservice With VB 6.0 COM Interop By Peter A. Bromberg, Ph.D. Printer-Friendly Version Peter Bromberg In this the results in an HTML Table. Finally, I'll show you the code for a VB 6.0 classic COM component that does the exact same Microsoft Search Service "Screenscrape" as the