Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Problem using VB6 (not VBA) to put picture file into Excel

  Asked By: Rani    Date: Dec 12    Category: MS Office    Views: 1977
  

I'm having some problems with using VB6 (not VBA) to place "picture
files" into Excel, specifically:

1. How to delete the previous one (and get its picture "number")
2. How to stretch the picture.

Here is what I can do:

1. I've got a custom chart requirement to show one day of stock
market activity. The charting capabilities of Excel are wanting, so
I create the chart with VB using a PictureBox. After I create the
PB, I save it using the following code:

PB1.Picture = PB1.Image
SavePicture PB1.Picture, "c:\temp\pic1.bmp"

2. I then insert it into Excel using the following code:

Dim MyXL As Excel.Workbook
Dim MyXLSh As Excel.Worksheet
Set MyXL = GetObject("c:\temp\stocks.xls")
Set MyXLsh = MyXL.Worksheets(1)
MyXLSh.Cells(1,1).Select
MyXL.ActiveSheeet.Pictures.Insert("c:\temp\pic1.bmp").Select

So far, so good. All done under program control. But from here, I
need to resort to manual manipulation, which I'd like to automate.

I reuse this sheet alot. So, the first thing need to do is to delete
the previous version of "c:\temp\pic1.bmp". This is complicated by
the fact that even though I only have 1 "chart" on the sheet, but
have previously inserted and subsequently deleted, say 20 times, the
new inserted picture is identified as "picture 21".
.. So, how do I find the picture number of the most recent old one?
.. And, what is the code to delete it?

Then, I need to manually increase the size of the "chart", by
dragging the lower right corner.
.. What is the code to enlarge it?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Problem using VB6 (not VBA) to put picture file into Excel Or get search suggestion and latest updates.




Tagged: