Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default problem using ActiveSheet in VB sub

I am using ActiveSheet in a Sub to insert a picture into a workbook,
like this:

ActiveSheet.Range(tsRangeIn).Select
ActiveSheet.Pictures.Insert( _
"C:\inetpub\wwwroot\Images\sig.jpg").Select

There are two places from within a single class file where the sub is
called. Every time I call the sub from one of these places in the
code, I get an "invalid procedure call or argument" error when setting
the Range property. The other call to the Sub works correctly every
time. Is there anything about the ActiveSheet that may cause it to
bomb depending on the context its used in? I'm rather new to VB Excel
programming, so any help is appreciated.

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default problem using ActiveSheet in VB sub

Matt,

It would fail if the named range was on a sheet other than the activesheet.
So when it bombs, have you changed the sheet some way?

Activesheet is a dodgy object to use, far better to use a specific sheet
object,like so
Dim oWsSummmary as worksheet, oWsDetail as Worksheet

Set oWsSummary = Worksheets"Summary")
Set oWsDetail = Worksheets("Detail")

and refer to these specfific objects

oWsSummary.Range("myRange").Value = "test"

--

HTH

Bob Phillips

"Matt" wrote in message
om...
I am using ActiveSheet in a Sub to insert a picture into a workbook,
like this:

ActiveSheet.Range(tsRangeIn).Select
ActiveSheet.Pictures.Insert( _
"C:\inetpub\wwwroot\Images\sig.jpg").Select

There are two places from within a single class file where the sub is
called. Every time I call the sub from one of these places in the
code, I get an "invalid procedure call or argument" error when setting
the Range property. The other call to the Sub works correctly every
time. Is there anything about the ActiveSheet that may cause it to
bomb depending on the context its used in? I'm rather new to VB Excel
programming, so any help is appreciated.

Matt



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
ActiveCell or ActiveSheet Launchnet Excel Worksheet Functions 1 July 20th 07 07:46 PM
ActiveSheet.Name? Andrew Stedman Excel Programming 5 July 30th 03 01:17 PM
ActiveSheet Graham[_3_] Excel Programming 0 July 30th 03 09:08 AM
ActiveSheet Ron de Bruin Excel Programming 0 July 29th 03 04:59 PM
ActiveSheet Graham[_3_] Excel Programming 0 July 29th 03 04:47 PM


All times are GMT +1. The time now is 06:44 PM.

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"