Insert Picture to Excel to specified range

B

Budiono

i want to insert picture from disk to excel using visual basic 6. i've use
following code:

dim oApp As New Excel.Application
dim oWkbk As Excel.Workbook
dim oSheet As Excel.Worksheet

ActiveCell.Range("A100").Activate
ActiveSheet.Pictures.Insert ("C:\TEMP.BMP")

the problem is, the picture is to large and i want to insert that picture
only from cell A100 to E120.
which function i should use?

any help would be greatly appreciate..
thanks
 
K

keepitcool

Sub Linked()
Dim s As Shape
With [b5]
Set s = .Parent.Shapes.AddPicture("D:\Documents\!Pictures\marg_v1.png",
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.5, msoTrue
.ScaleWidth 0.5, msoTrue
End With
End Sub

demo shows insertion with cell's size then scales to 50% of original
(saved) size

look in VBA help for meaning of arguments.

cheerz!


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
B

Budiono

i've try ur code but it doesn't work :(
what do you mean with '[b5]' ?

keepitcool said:
Sub Linked()
Dim s As Shape
With [b5]
Set s = .Parent.Shapes.AddPicture("D:\Documents\!Pictures\marg_v1.png",
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.5, msoTrue
.ScaleWidth 0.5, msoTrue
End With
End Sub

demo shows insertion with cell's size then scales to 50% of original
(saved) size

look in VBA help for meaning of arguments.

cheerz!


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


Budiono said:
i want to insert picture from disk to excel using visual basic 6. i've
use following code:

dim oApp As New Excel.Application
dim oWkbk As Excel.Workbook
dim oSheet As Excel.Worksheet

ActiveCell.Range("A100").Activate
ActiveSheet.Pictures.Insert ("C:\TEMP.BMP")

the problem is, the picture is to large and i want to insert that
picture only from cell A100 to E120.
which function i should use?

any help would be greatly appreciate..
thanks
 
K

keepitcool

[b5] is short code for range("b5") on the activesheet
[sheet3!b5)=worksheets("sheet3").range("b5")

it probably doesnt work due to linebreaks or file not found.
for me the principle works in xl97 & xlxp


adjusted it would look like:

Sub Linked()
Dim s As Shape
With [a100]
Set s = .Parent.Shapes.AddPicture( _
"C:\TEMP.BMP", _
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.5, msoTrue
.ScaleWidth 0.5, msoTrue
End With
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


Budiono said:
i've try ur code but it doesn't work :(
what do you mean with '[b5]' ?

keepitcool said:
Sub Linked()
Dim s As Shape
With [b5]
Set s = .Parent.Shapes.AddPicture("D:\Documents\!Pictures \marg_v1.png",
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.5, msoTrue
.ScaleWidth 0.5, msoTrue
End With
End Sub

demo shows insertion with cell's size then scales to 50% of original
(saved) size

look in VBA help for meaning of arguments.

cheerz!


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


Budiono said:
i want to insert picture from disk to excel using visual basic 6. i've
use following code:

dim oApp As New Excel.Application
dim oWkbk As Excel.Workbook
dim oSheet As Excel.Worksheet

ActiveCell.Range("A100").Activate
ActiveSheet.Pictures.Insert ("C:\TEMP.BMP")

the problem is, the picture is to large and i want to insert that
picture only from cell A100 to E120.
which function i should use?

any help would be greatly appreciate..
thanks
 
B

Budiono

thanks for your replay, but i still have diffilculties.
do you mean that sub procedure as a macro that i've to save it to .bas file?
i've save it to .bas file and then do the following code:

oWkbk.VBE.ActiveVBProject.VBComponents.Import "C:\picsize.bas" 'i've save
your code to file picsize.bas
oWkbk.Run "picsize", oSheet

but it doesn't work :(
where i can file for VBA help files?
thanks :)
 
B

Budiono

i've tried again n it's work. thanks :)

keepitcool said:
[b5] is short code for range("b5") on the activesheet
[sheet3!b5)=worksheets("sheet3").range("b5")

it probably doesnt work due to linebreaks or file not found.
for me the principle works in xl97 & xlxp


adjusted it would look like:

Sub Linked()
Dim s As Shape
With [a100]
Set s = .Parent.Shapes.AddPicture( _
"C:\TEMP.BMP", _
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.5, msoTrue
.ScaleWidth 0.5, msoTrue
End With
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


Budiono said:
i've try ur code but it doesn't work :(
what do you mean with '[b5]' ?

keepitcool said:
Sub Linked()
Dim s As Shape
With [b5]
Set s = .Parent.Shapes.AddPicture("D:\Documents\!Pictures \marg_v1.png",
True, True, .Left, .Top, .Width, .Height)
End With
With s
.ScaleHeight 0.5, msoTrue
.ScaleWidth 0.5, msoTrue
End With
End Sub

demo shows insertion with cell's size then scales to 50% of original
(saved) size

look in VBA help for meaning of arguments.

cheerz!


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >



i want to insert picture from disk to excel using visual basic 6. i've
use following code:

dim oApp As New Excel.Application
dim oWkbk As Excel.Workbook
dim oSheet As Excel.Worksheet

ActiveCell.Range("A100").Activate
ActiveSheet.Pictures.Insert ("C:\TEMP.BMP")

the problem is, the picture is to large and i want to insert that
picture only from cell A100 to E120.
which function i should use?

any help would be greatly appreciate..
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top