473,657 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type conversion error

2 New Member
Hey guys..i jus thought if u cud help me out wit this error im gettin.
Im writing a c# code to create an add-in in visio using VSTO.
I found this code which was in VB and i'm tryin to convert it to c# :

VB
Dim commandBars As Office.CommandB ars
Dim commandBar As Office.CommandB ar

commandBars = Application.Com mandBars
commandBar = commandBars.Add ("Demo Toolbar", _
Office.MsoBarPo sition.msoBarTo p, , True)
' Set the context when the toolbar is visible.
commandBar.Cont ext = Visio.VisUIObjS ets.visUIObjSet Drawing & "*"

' Add a button with a smiley face icon.
DemoButton = _
commandBar.Cont rols.Add(Office .MsoControlType .msoControlButt on)
DemoButton.Tag = "Demo Button"
DemoButton.Face Id = 2950
DemoButton.Tool tipText = "Run Demo"

c#
private void ThisAddIn_Start up(object sender, System.EventArg s e)
1 {
2 Microsoft.Offic e.Core.CommandB ars commandBars;
3 Microsoft.Offic e.Core.CommandB ar commandBar;

4 commandBars = Application.Com mandBars;
5 commandBar = commandBars.Add ("Demo Toolbar",Office .MsoBarPosition .msoBarTop,"",t rue);
//set the context menu when the toolbar is visible.
6 commandBar.Cont ext = Visio.VisUIObjS ets.visUIObjSet Drawing & "*";

//add a button wth a smiley face icon

7 Microsoft.Offic e.Core.CommandB arButton DemoButton = (Microsoft.Offi ce.Core.Command BarButton)comma ndBar.Controls. Add(Office.MsoC ontrolType.msoC ontrolButton,"" ,"","","");
8 DemoButton.Tag = "Demo Button";
9 DemoButton.Face Id = 2950;
10 DemoButton.Tool tipText= "Run Demo";



}

the error i'm gettin:


line 4:
:Cannot implicitly convert type 'bject' to 'Microsoft.Offi ce.Core.Command Bars'. An explicit conversion exists(you are missing a cast?)

line 6: Operator '&' cannot be applied to operands of type 'Microsoft.Offi ce.Interop.Visi o.VisUIObjects' and 'string'

Plz help me out wit this error. Thanks in advance
Mar 12 '07 #1
0 1474

Sign in to post your reply or Sign up for a free account.

Similar topics

21
2507
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A String Literal";//the compiler isuues no error/warning here // but ideally it should...as p is a non-const
4
11961
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column 14 (STDCOST). ---End Error Msg--- The STDCOST is set to decimal (28,14) and is a formatted in Access as a number, single with 14 decimal. I don't know why I would be getting a Type
27
5631
by: Yuriy Solodkyy | last post by:
Hi VS 2005 beta 2 successfully compiles the following: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
3
1875
by: pgconnolly | last post by:
/* foreach does implicit type conversion on elements of a params argument or Generic.List. * This is not good. * Examples of evil follow... */ using System; // I love it when C# is strict with me... using System.Collections.Generic;
1
3273
by: lovecreatesbeauty | last post by:
There is a warning/(error? I remember it is an error for line 10 on some compilers before. At least on g++, it is an error.) for line 10. I first read a similar example from `Expert C Programming -- Deep Secrets, Perter van der Linden'. But I wonder why line 9 is ok but line 10 is illegal? Is what Keith Thompson said in another post also helpful to understand this question: "... The implicit conversion rule applies only to void*, not...
6
2794
by: Dhirendra Singh | last post by:
Hi, The following C++ program is not compiling on my system. #include <iostream> using namespace std; class complex { double re, im; public: complex( ) :re(0), im(0) {}
669
25859
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
8
3144
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the developer. x = someObject as MySpecificType; x = (MySpecificType) someObject; Thanks.
6
2629
by: Rahul | last post by:
Hi Everyone, I have the following code, class B; class A { public : operator B();
10
15759
by: preeya | last post by:
Hi, I have written the following program: ------------------------------------------------------------------------------------------------------------- 1 #include <stdio.h> 2 #include "abc.h" 3 4 void PROP_abc(double ptr)
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.