Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PS PS is offline
external usenet poster
 
Posts: 18
Default How do I search for a .bmp in a worksheet using VBA in Excel

Let me preface by saying I am new to VBA. I have a macro which searches for
a block of text, if it is present, it is removed and replaced by an image.

If the image is present, I don't want anything to change. I do not know how
to reference the .bmp file/"named" image, and I don't want the image
re-inserted by the macro.

Can anyone help? Provide suggestions or alternate places for me to look for
help?

I'd appreciate any guidance. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I search for a .bmp in a worksheet using VBA in Excel


The .bmp must exist in a container such as a shape or a drawingobject
you will need to cylce through these to see if the fill is a picture.
But I am not sure if the actual file name and type is kept for all
containers

hope this helps


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=530701

  #3   Report Post  
Posted to microsoft.public.excel.programming
PS PS is offline
external usenet poster
 
Posts: 18
Default How do I search for a .bmp in a worksheet using VBA in Excel

Thanks, but I must be doing something else wrong, because the code just isn't
working. I'll keep looking; I appreciate your help!

PS

"tony h" wrote:


The .bmp must exist in a container such as a shape or a drawingobject
you will need to cylce through these to see if the fill is a picture.
But I am not sure if the actual file name and type is kept for all
containers

hope this helps


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=530701


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I search for a .bmp in a worksheet using VBA in Excel


You could post the code here


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=530701

  #5   Report Post  
Posted to microsoft.public.excel.programming
PS PS is offline
external usenet poster
 
Posts: 18
Default How do I search for a .bmp in a worksheet using VBA in Excel

Hey, tony h, sorry for the delay in getting back...

Here's the code. Some of it I did by "recording", the rest I winged it. I
get fowled up at the end... each time the sheet updates, the .bmps are
reinserted. I was trying to find the company name & if it's there replace it
with the bmp. Then, the next time the sheet is updated, if the bmp is there,
I don't want it to do anything. (This is just a small portion of a very
large set of macros which perform some automation.)

Up to the ElseIF portion it seems to run fine, but I don't kow how to stop
the code from reinserting the bmps, so I thought I could have it search for
the "extra" set each time and just delete it.

If you can help any further, I'd be obliged. (Does the "recorder" add
extraneous information -- more than you need to know?" It just seems so
cumbersome.)

Here's the code... thanks again, PS

Cells.Find(What:="ABC Co", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Select
If ActiveCell.Value = "ABC Co" Then
Selection.ClearContents
ActiveSheet.Pictures.Insert("C:\Documents and Settings\PS\Desktop\ABC
Co\FileTransfer\Xmtls\XmtlLogo-DoNotRelocate.bmp").Select
' ActiveSheet.Pictures.Insert("H:\misc\XmtlLogo-DoNotRelocate.bmp").Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 12#
Selection.ShapeRange.Width = 78#
Selection.ShapeRange.Rotation = 0#
Selection.Name = "Logo"
With Selection
.Placement = xlFreeFloating
.PrintObject = True
End With
Selection.ShapeRange.IncrementTop 0.75
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
ActiveCell.Select
ActiveSheet.Pictures.Insert("C:\Documents and Settings\PS\Desktop\ABC
Co\FileTransfer\Xmtls\Xmtl-em-DoNoRelocate.bmp").Select
' ActiveSheet.Pictures.Insert("H:\misc\Xmtl-em-DoNoRelocate.bmp").Select
Selection.Name = "EMsign"
With Selection
.Placement = xlFreeFloating
.PrintObject = True
End With
Selection.ShapeRange.IncrementTop 0.75
Selection.ShapeRange.IncrementTop 0.75
Selection.ShapeRange.IncrementTop 0.75

ElseIf ActiveSheet.Shapes.Find(What:="Logo", After:=ActiveCell,
LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate Then
ActiveSheet.Shapes(Array("Logo", "EMsign")).Delete

Sheets("TRANSMITAL").Select
End If

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios _
:=True
End Sub



"tony h" wrote:


You could post the code here


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=530701




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
Search one worksheet to pull data into another worksheet HyperMite Excel Worksheet Functions 6 March 4th 09 01:53 PM
Search for Excel worksheet in Windows Explorer using dollar value Bill Wilson[_2_] Excel Discussion (Misc queries) 9 November 17th 07 09:15 PM
Disable Search Function In Excel Worksheet Dileep Excel Worksheet Functions 0 September 29th 06 09:59 AM
I want to enter a name then have EXCEL search a worksheet for add. rjdavis Excel Programming 1 August 30th 05 02:22 PM
Create a search Field within a worksheet to search command buttons Ed P[_2_] Excel Programming 1 December 14th 04 08:04 PM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"