PC Review


Reply
Thread Tools Rate Thread

Confusing Runtime Error

 
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      21st Jul 2007
I'm getting a mismatch error when I install my custom add-in, but it doesn't
make sense. Below is my code:

Set myButton = myBar.Controls.Add(Type:=msoControlButton)
With myButton
If Application.Calculation = xlCalculationManual Then
.FaceId = 349
.TooltipText = "Click here to set calculation method to
AUTOMATIC."
Else
.FaceId = 346
.TooltipText = "Click here to set calculation method to MANUAL."
End If
end with

When Excel is first started, the error occurs at the
"Application.Calculation" line. However, when I enter the debugger and step
through, the code continues without error. If this add-in is installed after
the application has fully started, then there seems to be no problem.

I see that when no workbook is open, the Options settings are unavailable.
Is there any way to check if the application has fully started?

Thanks,
Pflugs
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      21st Jul 2007
I think you'd be better served to not worry about any workbook being
opened--just create one yourself and close it when you're done.



Dim tempWkbk as workbook
Set tempwkbk = workbooks.add

'your code to add the buttons

'and then close the workbook
temwkbk.close savechanges:=false





Pflugs wrote:
>
> I'm getting a mismatch error when I install my custom add-in, but it doesn't
> make sense. Below is my code:
>
> Set myButton = myBar.Controls.Add(Type:=msoControlButton)
> With myButton
> If Application.Calculation = xlCalculationManual Then
> .FaceId = 349
> .TooltipText = "Click here to set calculation method to
> AUTOMATIC."
> Else
> .FaceId = 346
> .TooltipText = "Click here to set calculation method to MANUAL."
> End If
> end with
>
> When Excel is first started, the error occurs at the
> "Application.Calculation" line. However, when I enter the debugger and step
> through, the code continues without error. If this add-in is installed after
> the application has fully started, then there seems to be no problem.
>
> I see that when no workbook is open, the Options settings are unavailable.
> Is there any way to check if the application has fully started?
>
> Thanks,
> Pflugs


--

Dave Peterson
 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      21st Jul 2007
Application.Calculation, Read/Write, requires a visible workbook in place,
ie an active workbook. Defer your routine by calling with the Ontime method.
'Now' is OK, it won't run until everything related to Startup is done, in
particular an active workbook is present.

Regards,
Peter T

"Pflugs" <(E-Mail Removed)> wrote in message
news:EA8F7051-2349-487B-914F-(E-Mail Removed)...
> I'm getting a mismatch error when I install my custom add-in, but it

doesn't
> make sense. Below is my code:
>
> Set myButton = myBar.Controls.Add(Type:=msoControlButton)
> With myButton
> If Application.Calculation = xlCalculationManual Then
> .FaceId = 349
> .TooltipText = "Click here to set calculation method to
> AUTOMATIC."
> Else
> .FaceId = 346
> .TooltipText = "Click here to set calculation method to

MANUAL."
> End If
> end with
>
> When Excel is first started, the error occurs at the
> "Application.Calculation" line. However, when I enter the debugger and

step
> through, the code continues without error. If this add-in is installed

after
> the application has fully started, then there seems to be no problem.
>
> I see that when no workbook is open, the Options settings are unavailable.
> Is there any way to check if the application has fully started?
>
> Thanks,
> Pflugs



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confusing Error - Please Help!!! mahesh.nimbalkar@gmail.com Microsoft Dot NET Framework Forms 1 27th May 2007 04:19 PM
Confusing error message John J. Hughes II Microsoft C# .NET 3 22nd Sep 2006 10:21 PM
Confusing error message Josh Microsoft Access Forms 0 11th Aug 2004 01:19 PM
confusing error mgm Windows XP General 0 28th Aug 2003 05:10 AM
confusing error using .NET C++ Al Havrilla Microsoft VC .NET 0 13th Aug 2003 07:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:14 AM.