tamaño imagen

03/05/2005 - 22:22 por fredy | Informe spam
hola grupo

tengo la siguiente macro (aparte)

Private Sub UpdateChart()
Set currentchart = Sheets("graf").ChartObjects(ChartNum).Chart

'config xa 1152*864
currentchart.Parent.Width = 587
currentchart.Parent.Height = 290

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
currentchart.Export Filename:=Fname, FilterName:="GIF"

' Show the chart
Image1.Picture = LoadPicture(Fname)

End Sub

lo que hace es a partir de un chart crear una imagen para mostrarla en un
formulario, lo que pasa es que cuando la pongo en otro computador con otra
resolucion de pantalla el tamaño de la imagen no siempre es legible, existe
alguna forma de que estas lineas

currentchart.Parent.Width = 587
currentchart.Parent.Height = 290

del codigo cambien dependiendo de la resolucion de la pantalla?, la imagen
la estoy colocando en un campo de imagen de 600x300 que esta en un formulario.
O que forma existe para obtener siempre imagenes claras sin kinportar la
resolucionde la pantalla?
muchas gracias! ;D

el codigo original fue tomado de
http://j-walk.com/ss/excel/tips/tip66.htm
 

Leer las respuestas

#1 KL
04/05/2005 - 00:07 | Informe spam
Hola Fredy,

El mismo John Walkenbach te ofrece la forma de saber la resolucion de
pantalla aqui: http://j-walk.com/ss/excel/tips/tip06.htm

Ahora ya podrias hacer algo como lo que te pongo a continuacion (solo
tendras que asignar los valores a las variables "w" y "h".

Saludos,
KL

'-Inicio Codigo-
' 32-bit API declaration
Declare Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

' 16-bit API declaration
Declare Function GetSystemMetrics16 Lib "user" _
Alias "GetSystemMetrics" (ByVal nIndex As Integer) As Integer

Public Const SM_CYSCREEN = 1

Private Sub UpdateChart()
Set currentchart = Sheets("graf").ChartObjects(ChartNum).Chart

If Left(Application.Version, 1) = 5 Then
' 16-bit Excel
vidHeight = GetSystemMetrics16(SM_CYSCREEN)
Else
' 32-bit Excel
vidHeight = GetSystemMetrics32(SM_CYSCREEN)
End If
Select Case vidHeight
Case 480 To 680
w h Case 768 To 900
w h Case 1000 To 1280
w h Else
w h End Select

'currentchart.Parent.Width =w
'currentchart.Parent.Height =h

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
currentchart.Export Filename:=Fname, FilterName:="GIF"

' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub

Preguntas similares