Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

This is pretty simple. I want to add a button to my
sheet--programatically. When I do it programatically the project stops.
Is there a workaround?

ThisWorkbook.Worksheets("Market
Report").OLEObjects.ADD(ClassType:="Forms.CommandB utton.1", Link:=False
_
, DisplayAsIcon:=False, Left:=2.25, Top:=256.5, Width:=18.75,
Height _
:=9).Select

Timothy Marks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Are you stepping through the code when it stops (using F8's?). If yes, then
don't step through it.

Maybe set a break point after that line of code???

Timothy Marks wrote:

This is pretty simple. I want to add a button to my
sheet--programatically. When I do it programatically the project stops.
Is there a workaround?

ThisWorkbook.Worksheets("Market
Report").OLEObjects.ADD(ClassType:="Forms.CommandB utton.1", Link:=False
_
, DisplayAsIcon:=False, Left:=2.25, Top:=256.5, Width:=18.75,
Height _
:=9).Select

Timothy Marks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Nope. It all resets and dissapears, cleared all breaks. When the item
finishes it appears the command button that I just created has the
focus and it appears to be in development mode on the sheet with all
the little control dots around it i.e.

.. . .
.. . .

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Hi Tim
If you're using XL97or below (they fixed it after that) then you need to
tell XL to remove the focus from the command button. I used to find
something simple like Range("A1").Select did the trick OK.

HTH
Best rgds
Chris Lav

"Timothy Marks" wrote in message
oups.com...
Nope. It all resets and dissapears, cleared all breaks. When the item
finishes it appears the command button that I just created has the
focus and it appears to be in development mode on the sheet with all
the little control dots around it i.e.

. . .
. . .



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Sorry, I don't have a guess.

Timothy Marks wrote:

Nope. It all resets and dissapears, cleared all breaks. When the item
finishes it appears the command button that I just created has the
focus and it appears to be in development mode on the sheet with all
the little control dots around it i.e.

. . .
. . .


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

I have Excel 2003 SP1. I restarted Excel, I set a reference to a range
way off the sheet. The code goes to set the reference but then the
project still ends. Something I have the code snippet I have which I
copied from a macro is allowing it to go into debug mode. Any ideas?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Here is what I use...

Dim wks As Worksheet
Dim wbk As Workbook
Dim cmdButton As OLEObject

Set wks = ActiveSheet
Set wbk = ActiveWorkbook

Set cmdButton = wks.OLEObjects.Add(ClassType:="Forms.CommandButton .1",
Height:=23, Width:=80)

With cmdButton
.Top = ActiveCell.Top
.Left = ActiveCell.Left
.Object.Caption = "Tada"
.Object.FontSize = 10
.Object.Font.Bold = False
.Object.Font.Underline = False
.Name = "cmdMyButton"
.PrintObject = False
End With
--
HTH...

Jim Thomlinson


"Timothy Marks" wrote:

This is pretty simple. I want to add a button to my
sheet--programatically. When I do it programatically the project stops.
Is there a workaround?

ThisWorkbook.Worksheets("Market
Report").OLEObjects.ADD(ClassType:="Forms.CommandB utton.1", Link:=False
_
, DisplayAsIcon:=False, Left:=2.25, Top:=256.5, Width:=18.75,
Height _
:=9).Select

Timothy Marks


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Jim I did try that but that does not seem to work either. Do i have
some enviormental setting that may be causing this.

Timothy.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default OLEObjects.ADD causes excel vba project to stop / reset / go d

Not sure if this causes a problem in 2003, but you could try...
Select Tools - Macro's - Security - Trusted Sources. Check Allow Access
to Visual Basic Project. I don't use 2003 here at work so I can ot test it
for you...
--
HTH...

Jim Thomlinson


"Timothy Marks" wrote:

Jim I did try that but that does not seem to work either. Do i have
some enviormental setting that may be causing this.

Timothy.


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default OLEObjects.ADD causes excel vba project to stop / reset / go d

I have both checked, Trust access to VBP and Trust all removed all add
ins and templates. I then deleted all trusted sources and add-ins.
Nothing has worked. :(



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Maybe there is.

Close excel and clean up that windows temp file.

Windows start button|Run
%temp%

Excel stores lots of stuff associated with objects in this temp folder. Maybe
there are lots of them and excel is getting confused.

ps. You may want to close other applications when you do this so you don't
break anything. (I don't bother, but some do.)

Timothy Marks wrote:

Jim I did try that but that does not seem to work either. Do i have
some enviormental setting that may be causing this.

Timothy.


--

Dave Peterson
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

I rebooted my computer, I then cleared out my temp directory. All apps
were restarted. Still have the same result. :(

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default OLEObjects.ADD causes excel vba project to stop / reset / go dead

Your code worked fine for me in my simple test workbook.

Does it work in a brand new workbook for you?

(I got nothing either way, though.)

Timothy Marks wrote:

I rebooted my computer, I then cleared out my temp directory. All apps
were restarted. Still have the same result. :(


--

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
How to convert MS Project to MS Excel. I don't have MS Project. Jane Excel Discussion (Misc queries) 1 February 20th 06 10:01 PM
With VBA from Excel: Open Project, extract resource list and copy it to a worksheet, close project. Tony Excel Programming 1 October 18th 05 03:53 PM
OLEObjects Roy[_8_] Excel Programming 1 May 6th 05 03:51 AM
OLEObjects .. again Roy[_8_] Excel Programming 3 December 17th 04 09:44 AM
Glolbal Variables Reset when using OleObjects Rock Excel Programming 11 May 31st 04 03:00 AM


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