Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Error when code runs

Sub Button36_Click()
On Error Resume Next
Range("C97").Select
Application.ScreenUpdating = False
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim myPic As Picture
Dim res As Variant
'Const sAddress As String = ActiveCell
Set WB = ActiveWorkbook
res = Application.GetOpenFilename("Image Files (*.jpg), *.jpg")
If res = False Then Exit Sub
Set SH = ActiveSheet
Set rng = ActiveCell
Set myPic = SH.Pictures.Insert(res)
With myPic
.Top = rng.Top
.Left = rng.Left
myPic.ShapeRange.LockAspectRatio = msoFalse
myPic.ShapeRange.Height = 215.1
myPic.ShapeRange.Width = 250#
myPic.ShapeRange.Rotation = 0#
'myPic.Name = ActiveCell.Offset(-1, 1).Value
End With
Application.ScreenUpdating = True
Range("L101").Select
End Sub

The above code when run prompts for a image selection and pastes it to size on a sheet.

However, i am now getting an error.

McAffee Buffer overflow Blocked. Then saying something about address.

I think it may be because the default folder it looks to is on a network.
Is there a way for me to add a line of code to look to a local folder instead?

Corey...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Error when code runs

What is your understanding of "On Error Resume Next" ? Should you be using
it in this situation ?
Remove it and see what happens.

As for the error, it appear related to your virus scanner. Why it should be
concerned about this code, I can't say, but a buffer overflow is a classic
menas of running dubious code. That message would appear to be either a
false positive or you actually have some other virus/bad code running also.

To change to path used, add:

ChDrive "C" 'Or whatever letter you want
res = Application.GetOpenFilename("Image Files (*.jpg), *.jpg")

NickHK

"Corey" wrote in message
...
Sub Button36_Click()
On Error Resume Next
Range("C97").Select
Application.ScreenUpdating = False
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim myPic As Picture
Dim res As Variant
'Const sAddress As String = ActiveCell
Set WB = ActiveWorkbook
res = Application.GetOpenFilename("Image Files (*.jpg), *.jpg")
If res = False Then Exit Sub
Set SH = ActiveSheet
Set rng = ActiveCell
Set myPic = SH.Pictures.Insert(res)
With myPic
.Top = rng.Top
.Left = rng.Left
myPic.ShapeRange.LockAspectRatio = msoFalse
myPic.ShapeRange.Height = 215.1
myPic.ShapeRange.Width = 250#
myPic.ShapeRange.Rotation = 0#
'myPic.Name = ActiveCell.Offset(-1, 1).Value
End With
Application.ScreenUpdating = True
Range("L101").Select
End Sub

The above code when run prompts for a image selection and pastes it to

size on a sheet.

However, i am now getting an error.

McAffee Buffer overflow Blocked. Then saying something about address.

I think it may be because the default folder it looks to is on a network.
Is there a way for me to add a line of code to look to a local folder

instead?

Corey...




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error when code runs

"McAffee Buffer overflow Blocked."

Are you sure it's not McAfee?

If it is McAfee, then it sounds like your antivirus software is causing the
trouble. I'd start by temporarily disabling the AV software and see what
happens.



Corey wrote:

Sub Button36_Click()
On Error Resume Next
Range("C97").Select
Application.ScreenUpdating = False
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim myPic As Picture
Dim res As Variant
'Const sAddress As String = ActiveCell
Set WB = ActiveWorkbook
res = Application.GetOpenFilename("Image Files (*.jpg), *.jpg")
If res = False Then Exit Sub
Set SH = ActiveSheet
Set rng = ActiveCell
Set myPic = SH.Pictures.Insert(res)
With myPic
.Top = rng.Top
.Left = rng.Left
myPic.ShapeRange.LockAspectRatio = msoFalse
myPic.ShapeRange.Height = 215.1
myPic.ShapeRange.Width = 250#
myPic.ShapeRange.Rotation = 0#
'myPic.Name = ActiveCell.Offset(-1, 1).Value
End With
Application.ScreenUpdating = True
Range("L101").Select
End Sub

The above code when run prompts for a image selection and pastes it to size on a sheet.

However, i am now getting an error.

McAffee Buffer overflow Blocked. Then saying something about address.

I think it may be because the default folder it looks to is on a network.
Is there a way for me to add a line of code to look to a local folder instead?

Corey...


--

Dave Peterson
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
vba code runs...need spaces ........ Wanna Learn Excel Discussion (Misc queries) 2 January 20th 09 12:44 PM
Code only runs once Kent Excel Programming 3 November 24th 05 03:47 PM
Code runs in 2002 but not in 97!? Big Chris[_39_] Excel Programming 4 August 25th 05 12:22 PM
Code slows down after a few runs Diverse Computing[_2_] Excel Programming 2 July 21st 05 04:08 AM
Code runs without error but doesn't print output Robert Hargreaves Excel Programming 1 May 27th 05 06:43 PM


All times are GMT +1. The time now is 02:33 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"