Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Pictures on modeless windows

Hi,

I have a sheet with the names of my students. I let the user see a picture
of them on a modeless window (so cells can still be modified). To see the
form with the picture, a button must be pressed on the toolbar.

Q1: when the form is displayed, how can I give back focus on the sheet
(without clicking on it)?
Q2: how can I prevent that the picture is stretched out (misformed) when it
is too small, but is always shrinked when it is too big (so you see the
whole picture without deformation). When I use a picture-object, I cannot
shrink, so I used a button (with picture), but the I get a deformation.

Can you help me?
Thanks
Jos Vens


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Pictures on modeless windows

Jos,

I set up UserForm1. I used the Image tool in the Toolbox, and made Image1.
I used to following code to show a modeless UserForm:

UserForm1.Show xlModeless
UserForm1.Image1.PictureSizeMode = fmPictureSizeModeZoom

To put focus back on the sheet, either or both of these:
'Sheets("Sheet1").Activate
'Sheets("Sheet1").Range("A2").Select

Then to change the picture, at any time:

PictureName = "C:\C5.jpg"
UserForm1.Image1.Picture = LoadPicture(PictureName)

It didn't deform the picture.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jos Vens" wrote in message
...
Hi,

I have a sheet with the names of my students. I let the user see a
picture of them on a modeless window (so cells can still be modified). To
see the form with the picture, a button must be pressed on the toolbar.

Q1: when the form is displayed, how can I give back focus on the sheet
(without clicking on it)?
Q2: how can I prevent that the picture is stretched out (misformed) when
it is too small, but is always shrinked when it is too big (so you see the
whole picture without deformation). When I use a picture-object, I cannot
shrink, so I used a button (with picture), but the I get a deformation.

Can you help me?
Thanks
Jos Vens



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Pictures on modeless windows

Thanks Earl,

I could solve my problems, except one thing:

When I'm on row 45, I jump to the next column row 5, so the user can put in
the next column of data. If I do this, the picture is not loaded. Even
when I force the Set_Picture procedure in the Workbook_SheetChange event, I
appears for an instant and then disappears.

Thanks
Jos Vens

I use the event

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

SET_Picture (Target.Row)

End Function

and the procedure

Function SET_Picture(vRow As Long, Optional vForce)

Dim vFile As String, vFolder As String, vExt As String

If (IsMissing(vForce)) Then
vForce = False
End If

If (Libra_FrmFoto.Visible) Or CBool(vForce) Then

If (vRow 4) And (vRow < 45) Then

vFolder = GET_pPath("Data", spParameters.[gCampus]) & "Foto\" &
spParameters.[gKlas] & "\"
If (HFS_Exist(vFolder)) Then

vFile = Dir(vFolder)
vExt = IIf(vFile = "", "", Right(vFile, 4))

Else

HFS_CreateDir vFolder
vExt = ""

End If

If (vExt = "") Then

Libra_FrmFoto.Caption = ""
Libra_FrmFoto.vFoto.Picture = LoadPicture("")

Else

vFile = vFolder & Format(vRow - 4, "00") & vExt

Libra_FrmFoto.Caption = ActiveSheet.Cells(vRow, 2)
Libra_FrmFoto.vFoto.Picture = LoadPicture(vFile)
Libra_FrmFoto.Repaint

End If

Else

Libra_FrmFoto.Caption = ""
Libra_FrmFoto.vFoto.Picture = LoadPicture("")

End If

End If

End Function





"Earl Kiosterud" schreef in bericht
...
Jos,

I set up UserForm1. I used the Image tool in the Toolbox, and made
Image1. I used to following code to show a modeless UserForm:

UserForm1.Show xlModeless
UserForm1.Image1.PictureSizeMode = fmPictureSizeModeZoom

To put focus back on the sheet, either or both of these:
'Sheets("Sheet1").Activate
'Sheets("Sheet1").Range("A2").Select

Then to change the picture, at any time:

PictureName = "C:\C5.jpg"
UserForm1.Image1.Picture = LoadPicture(PictureName)

It didn't deform the picture.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jos Vens" wrote in message
...
Hi,

I have a sheet with the names of my students. I let the user see a
picture of them on a modeless window (so cells can still be modified).
To see the form with the picture, a button must be pressed on the
toolbar.

Q1: when the form is displayed, how can I give back focus on the sheet
(without clicking on it)?
Q2: how can I prevent that the picture is stretched out (misformed) when
it is too small, but is always shrinked when it is too big (so you see
the whole picture without deformation). When I use a picture-object, I
cannot shrink, so I used a button (with picture), but the I get a
deformation.

Can you help me?
Thanks
Jos Vens





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Pictures on modeless windows

Jos,

I haven't looked at your code in much detail -- I don't know what some of
the stuff is. But since it fails when you jump to the top of the next
column (I don't see code that does that either), perhaps the
Selection_Change is getting fired again. If so, use

Application.EnableEvents = False ' prevent re-firing
change the selection
Applicationi.EnableEvents = True
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jos Vens" wrote in message
...
Thanks Earl,

I could solve my problems, except one thing:

When I'm on row 45, I jump to the next column row 5, so the user can put
in the next column of data. If I do this, the picture is not loaded.
Even when I force the Set_Picture procedure in the Workbook_SheetChange
event, I appears for an instant and then disappears.

Thanks
Jos Vens

I use the event

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

SET_Picture (Target.Row)

End Function

and the procedure

Function SET_Picture(vRow As Long, Optional vForce)

Dim vFile As String, vFolder As String, vExt As String

If (IsMissing(vForce)) Then
vForce = False
End If

If (Libra_FrmFoto.Visible) Or CBool(vForce) Then

If (vRow 4) And (vRow < 45) Then

vFolder = GET_pPath("Data", spParameters.[gCampus]) & "Foto\" &
spParameters.[gKlas] & "\"
If (HFS_Exist(vFolder)) Then

vFile = Dir(vFolder)
vExt = IIf(vFile = "", "", Right(vFile, 4))

Else

HFS_CreateDir vFolder
vExt = ""

End If

If (vExt = "") Then

Libra_FrmFoto.Caption = ""
Libra_FrmFoto.vFoto.Picture = LoadPicture("")

Else

vFile = vFolder & Format(vRow - 4, "00") & vExt

Libra_FrmFoto.Caption = ActiveSheet.Cells(vRow, 2)
Libra_FrmFoto.vFoto.Picture = LoadPicture(vFile)
Libra_FrmFoto.Repaint

End If

Else

Libra_FrmFoto.Caption = ""
Libra_FrmFoto.vFoto.Picture = LoadPicture("")

End If

End If

End Function





"Earl Kiosterud" schreef in bericht
...
Jos,

I set up UserForm1. I used the Image tool in the Toolbox, and made
Image1. I used to following code to show a modeless UserForm:

UserForm1.Show xlModeless
UserForm1.Image1.PictureSizeMode = fmPictureSizeModeZoom

To put focus back on the sheet, either or both of these:
'Sheets("Sheet1").Activate
'Sheets("Sheet1").Range("A2").Select

Then to change the picture, at any time:

PictureName = "C:\C5.jpg"
UserForm1.Image1.Picture = LoadPicture(PictureName)

It didn't deform the picture.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jos Vens" wrote in message
...
Hi,

I have a sheet with the names of my students. I let the user see a
picture of them on a modeless window (so cells can still be modified).
To see the form with the picture, a button must be pressed on the
toolbar.

Q1: when the form is displayed, how can I give back focus on the sheet
(without clicking on it)?
Q2: how can I prevent that the picture is stretched out (misformed) when
it is too small, but is always shrinked when it is too big (so you see
the whole picture without deformation). When I use a picture-object, I
cannot shrink, so I used a button (with picture), but the I get a
deformation.

Can you help me?
Thanks
Jos Vens







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Pictures on modeless windows

Hi Earl,

I found the solution!

The problem was the precedence of events:

First is executed
Private Sub Workbook_SheetChange(ByVal vSheet As Object, ByVal vCell As
Excel.Range)

Afterwards
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

In the SheetChange-event, I jumped to row 5, but for the
SheetSelectionChange, the activecell.row was still 45, so no picture was
shown. I force now the row with a global variable which holds the
active-jumprow (for me this is 5). In the picture settting, I use this row
in stead of the activerow (which still is 45).

thanks for your help!!!! (but I think this might be a bug in Excel?)

Jos


"Earl Kiosterud" schreef in bericht
...
Jos,

I haven't looked at your code in much detail -- I don't know what some of
the stuff is. But since it fails when you jump to the top of the next
column (I don't see code that does that either), perhaps the
Selection_Change is getting fired again. If so, use

Application.EnableEvents = False ' prevent re-firing
change the selection
Applicationi.EnableEvents = True
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jos Vens" wrote in message
...
Thanks Earl,

I could solve my problems, except one thing:

When I'm on row 45, I jump to the next column row 5, so the user can put
in the next column of data. If I do this, the picture is not loaded.
Even when I force the Set_Picture procedure in the Workbook_SheetChange
event, I appears for an instant and then disappears.

Thanks
Jos Vens

I use the event

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)

SET_Picture (Target.Row)

End Function

and the procedure

Function SET_Picture(vRow As Long, Optional vForce)

Dim vFile As String, vFolder As String, vExt As String

If (IsMissing(vForce)) Then
vForce = False
End If

If (Libra_FrmFoto.Visible) Or CBool(vForce) Then

If (vRow 4) And (vRow < 45) Then

vFolder = GET_pPath("Data", spParameters.[gCampus]) & "Foto\" &
spParameters.[gKlas] & "\"
If (HFS_Exist(vFolder)) Then

vFile = Dir(vFolder)
vExt = IIf(vFile = "", "", Right(vFile, 4))

Else

HFS_CreateDir vFolder
vExt = ""

End If

If (vExt = "") Then

Libra_FrmFoto.Caption = ""
Libra_FrmFoto.vFoto.Picture = LoadPicture("")

Else

vFile = vFolder & Format(vRow - 4, "00") & vExt

Libra_FrmFoto.Caption = ActiveSheet.Cells(vRow, 2)
Libra_FrmFoto.vFoto.Picture = LoadPicture(vFile)
Libra_FrmFoto.Repaint

End If

Else

Libra_FrmFoto.Caption = ""
Libra_FrmFoto.vFoto.Picture = LoadPicture("")

End If

End If

End Function





"Earl Kiosterud" schreef in bericht
...
Jos,

I set up UserForm1. I used the Image tool in the Toolbox, and made
Image1. I used to following code to show a modeless UserForm:

UserForm1.Show xlModeless
UserForm1.Image1.PictureSizeMode = fmPictureSizeModeZoom

To put focus back on the sheet, either or both of these:
'Sheets("Sheet1").Activate
'Sheets("Sheet1").Range("A2").Select

Then to change the picture, at any time:

PictureName = "C:\C5.jpg"
UserForm1.Image1.Picture = LoadPicture(PictureName)

It didn't deform the picture.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Jos Vens" wrote in message
...
Hi,

I have a sheet with the names of my students. I let the user see a
picture of them on a modeless window (so cells can still be modified).
To see the form with the picture, a button must be pressed on the
toolbar.

Q1: when the form is displayed, how can I give back focus on the sheet
(without clicking on it)?
Q2: how can I prevent that the picture is stretched out (misformed)
when it is too small, but is always shrinked when it is too big (so you
see the whole picture without deformation). When I use a
picture-object, I cannot shrink, so I used a button (with picture), but
the I get a deformation.

Can you help me?
Thanks
Jos Vens









Reply
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
How do you export pictures from my pictures file into a word docu Becky New Users to Excel 1 November 20th 09 07:02 PM
Storing Clip Art pictures in My Pictures folder jfg Excel Discussion (Misc queries) 4 August 10th 07 06:12 AM
Excel's Compress Pictures or deleting pictures doesn't seem work guidod Excel Discussion (Misc queries) 1 January 29th 06 06:51 AM
Modeless for in Windows XP jimbola Excel Programming 1 September 28th 04 01:35 PM
Modeless userform jacob[_3_] Excel Programming 2 September 29th 03 08:02 PM


All times are GMT +1. The time now is 04:34 AM.

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"