-
Align a picture in the center of the screen using VBA
Hi All,
I use Excel 2003. I have inserted a picture from Insert Menu, Picture, From File into a sheet. Is it possible to align the picture/shape in the center of the screen every time I run the this code below, is it possible to use StartUpPosition, how ?
[VBA]Sub SHOW_WAIT()
ActiveSheet.Shapes("Picture 1").Visible = True
End Sub[/VBA]
Thanks in advance
-
I'd put the pic on a userform and show that, userforms show centered by default. If you show the form using:
Userform1.Show vbModeLess
then your code continues to run after that line. Make sure you unload the form too:
Unload Userform1
-
Picture Alignment in the center of the screen (SOLVED)
Mr. Jan Karel,
Thanks for your response and kind attention, maybe it will much better if I use an UserForm as your suggestion.
Thanks a lot.
-
[VBA]Sub test()
Dim myPicture As Shape
Set myPicture = ActiveSheet.Shapes("Picture 1")
With ActiveWindow.VisibleRange
myPicture.Top = .Top + .Height / 2 - myPicture.Height / 2
myPicture.Left = .Left + .Width / 2 - myPicture.Width / 2
End With
myPicture.Visible = True
End Sub[/VBA]
-
Picture Alignment in the center of the screen (SOLVED)
Dear Mikerickson,
It's a great code. It worked fine ! Just like I want. It is visible right in the center of the screen or active window.
Thank you, thank you very very very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules