LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VSTO 2005 Excel picturebox control question

Im using VSTO 2005 to add some code to an Excel worksheet that allows the
user to click a button and select an image file to display in a picturebox
control. It seems successful, but when I save/close/reopen the worksheet,
the image displays briefly, then goes blank. Also, after saving the file
with an image it does increase the file size, so it appears that it is
embedded in the file.

Can someone explain to me why the image disappears and/or what I need to do
to
make the image persist???

Thanks.

I added a picturebox control (pictureBox1) and a button (cmdInsertPicture)
to a worksheet with the following code behind:

private void cmdInsertPicture_Click(object sender, EventArgs e)
{
string strImgFileFormat = "Image Files (*.bmp; *.jpg)|*.bmp;
*.jpg|Windows Bitmap (*.bmp)|*.bmp|JPEG File Interchange Format
(*.jpg)|*.jpg|All files (*.*)|*.*";
this.openFileDialog1.Filter = strImgFileFormat;
this.openFileDialog1.FileName = "";
this.openFileDialog1.InitialDirectory = Globals.ThisWorkbook.Path;
this.openFileDialog1.ShowDialog();
try
{
this.pictureBox1.Locked = false;
this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
// this.pictureBox1.Load(openFileDialog1.FileName); //both
methods work€¦
this.pictureBox1.Height = 275;
this.pictureBox1.Width = 275;
this.pictureBox1.Refresh();
}
catch (Exception ex)
{
MessageBox.Show("An image must be selected");
}
}

Sorry if some of you notice this is a duplicate post, I had an MSDN managed
newsgroups profile configuration problem which I believe I've resolved.
Hopefully now I can get expert answers to my technical questions within two
business days. :-)

--
-Doug
 
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
VSTO 2005 Excel picturebox question doug Excel Programming 0 July 25th 06 02:15 PM
VSTO 2005 Le Excel Programming 2 March 16th 06 04:46 PM
Calling functions developed in VSTO 2005 from Office Excel 2003 Neil Janabi Excel Programming 0 March 16th 06 10:50 AM
reference vsto Excel ListObject in Vb.Net 2005 project/app softengine Excel Programming 0 September 27th 05 08:21 PM
PictureBox control in VBA Excel form? Thomas Wieser Excel Programming 1 April 9th 04 09:15 PM


All times are GMT +1. The time now is 12:53 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"