Problem with Logos as pictures

O

Oggy

Hi

I have a system i have done for my business where i am putting
infomation requested via userforms into a spreadsheet, Excel 2007. I
have stored all my macros & userforms in an addin so that they are
all
in one location.


I have several logos save in one location on a server as bmp files,
(H:
\administration\Data Files\logo1.bmp) etc..


The user selects which logo is required via a userform amongst
other
things and upon pressing a Enter Button on the userform the code
opens
a template and puts all the infomation in including the logo using
the
following code.


Sub logo()
With Range("h2")
Set logo1 = .Parent.Pictures.Insert("H:\Administration
\Data files\logo1.bmp")
logo1.Top = .Top
logo1.Left = .Left
logo1.Width = 145
logo1.Height = 145
End With


End Sub


The spreadsheet has a button on it to run a code to toggle the logo
visable or not, (May need to print on headed paper, rather then
email)


Sub toggle()


logo1.Visible = Not logo1.Visible


End Sub


My problem is when the spreadsheet is closed , i lose the name to the
picture and when i reopen the at a later date to edit it etc... the
toggle code no longer works!


Does anyone know of a way around this problem its doing my head in!


Thanks in advance.
 
M

macropod

Hi Oggy,

If you name the shape, you can refer to it by name later on:
Sub logo()
Dim logo1 As Shape
With Range("H2")
Set logo1 = .Parent.Pictures.Insert("H:\Administration\Data files\logo1.bmp")
With logo1
.Top = .Top
.Left = .Left
.Width = 145
.Height = 145
.Name = "Logo1"
End With
End With
End Sub

Cheers
 
M

macropod

Make that:
Dim logo1 As Picture

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

macropod said:
Hi Oggy,

If you name the shape, you can refer to it by name later on:
Sub logo()
Dim logo1 As Shape
With Range("H2")
Set logo1 = .Parent.Pictures.Insert("H:\Administration\Data files\logo1.bmp")
With logo1
.Top = .Top
.Left = .Left
.Width = 145
.Height = 145
.Name = "Logo1"
End With
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Oggy said:
Hi

I have a system i have done for my business where i am putting
infomation requested via userforms into a spreadsheet, Excel 2007. I
have stored all my macros & userforms in an addin so that they are
all
in one location.


I have several logos save in one location on a server as bmp files,
(H:
\administration\Data Files\logo1.bmp) etc..


The user selects which logo is required via a userform amongst
other
things and upon pressing a Enter Button on the userform the code
opens
a template and puts all the infomation in including the logo using
the
following code.


Sub logo()
With Range("h2")
Set logo1 = .Parent.Pictures.Insert("H:\Administration
\Data files\logo1.bmp")
logo1.Top = .Top
logo1.Left = .Left
logo1.Width = 145
logo1.Height = 145
End With


End Sub


The spreadsheet has a button on it to run a code to toggle the logo
visable or not, (May need to print on headed paper, rather then
email)


Sub toggle()


logo1.Visible = Not logo1.Visible


End Sub


My problem is when the spreadsheet is closed , i lose the name to the
picture and when i reopen the at a later date to edit it etc... the
toggle code no longer works!


Does anyone know of a way around this problem its doing my head in!


Thanks in advance.
 
M

macropod

And here's some simple code to toggle the picture's visibility:
Sub Toggle()
With ActiveSheet.Pictures("Logo1")
.Visible = Not .Visible
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

macropod said:
Hi Oggy,

If you name the shape, you can refer to it by name later on:
Sub logo()
Dim logo1 As Shape
With Range("H2")
Set logo1 = .Parent.Pictures.Insert("H:\Administration\Data files\logo1.bmp")
With logo1
.Top = .Top
.Left = .Left
.Width = 145
.Height = 145
.Name = "Logo1"
End With
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Oggy said:
Hi

I have a system i have done for my business where i am putting
infomation requested via userforms into a spreadsheet, Excel 2007. I
have stored all my macros & userforms in an addin so that they are
all
in one location.


I have several logos save in one location on a server as bmp files,
(H:
\administration\Data Files\logo1.bmp) etc..


The user selects which logo is required via a userform amongst
other
things and upon pressing a Enter Button on the userform the code
opens
a template and puts all the infomation in including the logo using
the
following code.


Sub logo()
With Range("h2")
Set logo1 = .Parent.Pictures.Insert("H:\Administration
\Data files\logo1.bmp")
logo1.Top = .Top
logo1.Left = .Left
logo1.Width = 145
logo1.Height = 145
End With


End Sub


The spreadsheet has a button on it to run a code to toggle the logo
visable or not, (May need to print on headed paper, rather then
email)


Sub toggle()


logo1.Visible = Not logo1.Visible


End Sub


My problem is when the spreadsheet is closed , i lose the name to the
picture and when i reopen the at a later date to edit it etc... the
toggle code no longer works!


Does anyone know of a way around this problem its doing my head in!


Thanks in advance.
 
O

Oggy

Make that:
Dim logo1 As Picture

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------



macropod said:
If you name the shape, you can refer to it by name later on:
Sub logo()
Dim logo1 As Shape
With Range("H2")
 Set logo1 = .Parent.Pictures.Insert("H:\Administration\Data files\logo1.bmp")
 With logo1
   .Top = .Top
   .Left = .Left
   .Width = 145
   .Height = 145
   .Name = "Logo1"
 End With
End With
End Sub

- Show quoted text -

Thanks for your help,

It now errors saying i have not set an object when i try to toggle on
or off.

What reference should i have for the Picture Object

Thanks again
 
M

macropod

Hi Oggy,

The visibility toggling code I posted works for me. Were you using that or something different?

Cheers
 
O

Oggy

Hi Oggy,

The visibility toggling code I posted works for me. Were you using that or something different?

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------



Oggy said:
Thanks for your help,
It now errors saying i have not set an object when i try to toggle on or off.
What reference should i have for the Picture Object
Thanks again- Hide quoted text -

- Show quoted text -

Found it, because i inserted the logo twice in the same place the
toggled appeared not to work.

Would the same code work on a word document?

Thanks
 
M

macropod

Hi Oggy,

You can do something similar in Word, provided the picture is inserted and managed as a Shape object. Word has both Shapes and
InlineShapes, but only Shapes can be named. The toggling code in Word would be:

Sub Toggle()
With ActiveDocument.Shapes("Logo1")
.Visible = Not .Visible
End With
End Sub

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Oggy said:
Hi Oggy,

The visibility toggling code I posted works for me. Were you using that or something different?

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------



Oggy said:
Thanks for your help,
It now errors saying i have not set an object when i try to toggle on or off.
What reference should i have for the Picture Object
Thanks again- Hide quoted text -

- Show quoted text -

Found it, because i inserted the logo twice in the same place the
toggled appeared not to work.

Would the same code work on a word document?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top