How To List Worksheets of an Excel File in C#? Hi,
i have been dealing with it for 3 hours and couldnt figure out how i can list the worksheets in c#
is there anyone who had solved that thing,if theres can he/she tell me how can i do it
Thanks a lot... Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
How to add Category to taskItem? Hi,
I have some problems regarding adding a task to a category in outlook 2007 using VSTO 2005.
I created a Outlook.TaskItem and wanted to set a category to it but i cant find which properties to use. I have tried the Categorities property which dosent seem to work as it require a string but i don't think assigned a task to a category uses a string.
Pls help me. Thanks alot
Osprey Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Visual Basic vs. Visual C++ Which is a better application to use if the application has to interface with Excel A LOT
What are the pros and cons of both
I've used Visual Basic but haven't used Visual C++ with Excel Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Adding a macro to excel using C# in asp.net I am creating a customized excel report for my company using a webpage. Part of the excel file is a macro to handle printing though, and I can't seem to get it to work correctly. The code works... The page building the report impersonates a user that has access to Excel. Excel files can be created but, when I attempt to add the print macro I recieve this error: Programmatic access to Visual Basic Project is not trusted The user being impersonated has the security setting in excel set to: Trust access to Visual Basic Project I discovered on accident that if the impersonated user is actually logged in on the server that the code executes as expected, every time. If you have any idea how to correct this problem please let me know. Thank you in advance. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Howto set focus on newly opened word document (W 2003) Hi all!
I have an issue with opened documents.
When I do this:
FileInfo documentFile = _tempSaver . GetFromEdition(e . Data);
string documentPath = documentFile . FullName;
object boxedDocumentPath = ( object )documentPath;
object visible = ( object ) true ;
Microsoft . Office . Interop . Word . Document document = _thisAddIn . Application . Documents . Add( ref boxedDocumentPath, ref _null, ref _null, ref visible);
I see that Word instantly get's focus on newly opened document, and the next moment I see document that was the previous before adding new one.
I try to
document . Activate();
document . Application . ActiveWindow . SetFocus();
But still focus returns on that document that was current before openening new.
Is there a way to workaround this issue (I just need the focus stopped when i open new doc). I hope there is or else my users will eat my stomach.
Hope to hearing from you,
Ilya Cherkasov
RBC Soft. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
To override the "Forward" button in a mail Item Hi,
I have to override the "Forward" button in a mail Item whn User tries to forward Item from a particulare Folder.
the . GetInspector always throws an Error.
Is there somthin wrong in the way this is implemented
Please let me know
This is the code I am using:
Outlook. Explorer m_Explorer = _Explorers.Application.ActiveExplorer();
string strFolderName = m_Explorer.CurrentFolder.Name;
if (Equals(strFolderName, "Dont Allow Forward Folder" ))
{
object objItem;
objItem = Inspector.CurrentItem;
// If a Mail Item has been Opened From the "Secure Messages" Folder
if (objItem is Outlook. MailItem )
{
Outlook. MailItem mailItem = objItem as Outlook. MailItem ;
// HERE THERE IS AN EXCEPTION THROWN
// Inspector Menu BARs
m_InspectorMenuBar = m_MailItem. GetInspector. CommandBars.ActiveMenuBar;
// Inspector Menu BAR POPUP
m_InspectorCommandBarPopUp = (Office. CommandBarPopup )m_InspectorMenuBar.Controls[ "Forward" ];
}
} Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
The customization assembly could not be found or could not be loaded. Hi, I have started getting this when running my VSTO project inside the IDE. It was working before I deleted a couple of sheets out. If I create a new VSTO project it works fine. The DLL is getting created and is the right name. I've also turned on all exception under debugging, but it gives me no more information. Oh, and there is nothing in the details box! I am at a bit of a loss. Thanks Ray Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Sample for reading a Word 2007 document with C# or VB.NET? Word Programming Newbie here.
I've been browsing around trying to find a simple tutorial on how to read a Word 2007 document in VB.NET or C# and I can't seem to find any samples. Can anyone provide me a pointer
Specifically, I have a Word document template that people on my team use. The template includes a table that contains document status info. I'd like to be able to write a program to read the data in the table from all the documents in a directory and report on document status.
If anyone could give me a pointer to a sample that shows how to read data out of a Word 2007 doc I'd greatly appreciate it.
Thanks. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
How do I find text in a MS Word doc using VB2005 express? How do I find text in a MS Word doc using VB2005 express Can someone point me to some sample code perhaps Thanks Kim Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Discontiguous selection in Word 2007? I am developing a VSTO SE Addin for Word 2007. I need to determine if the user's current selection in Word 2007 is discontiguous (i.e., one or more non-adjacent paragraphs selected with Ctrl key), then handle accordingly.
The Selection.Type object does not seem to offer this information. Is there some way that I can find out if a discontiguous selection is made in the Word document
Thanks. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Speed: How to fill an Excel sheet quickly. I wish I knew! I'm using VSTO and Office 2003 and have written an Excel Add-in using the VS2005 project template for that.
It works beautifully and does everything I want. But it's so slow it's almost impractical to use.
Performance seems to have dropped radically aome stage and I can't diagnose why. In any case I'm frustrated by lack of knowledge on how to fille a worksheet quickly.
What I've implemented uses tips gather on-line. In essence I use a helper routine to write out rows to a sheet and it looks like this:
Code Block
public static Excel. Range SetRow(Excel. Worksheet worksheet, int row, int col, string [] values)
{
for ( int i = 0; i < values.Length; i++)
{
Excel. Range R = GetRange(worksheet, row, col + i);
R.Value2 = values[i];
}
return GetRange(worksheet, row, col, row, col + values.Length - 1);
}
This works a dream, but I can't help but feel there's not a better way to do this.
GetRange is another helper which uses the WorkSheet .get_Range method to get a range (it's overloaded clearly).
It loops through every cell in a row and gets that range and sets its Value2 property.
What I'd like actually is to prepare a two dimensional array and say "Copy this array to this worksheet" and that array can contain strings for the cells or for the formats to apply or values or whatever. But it should work as one slab copy and efficiently.
The code above writes out lines so slowly I can watch it walk down the worksheet as it writes and it'll take a noticeable time (20 seconds ) to fill the rows on my screen. This is abysmal.
Where are the inefficiencies and how can I speed this up Need to know more Happy to oblige.
Is anyone writing data out to a spreadsheet blindingly fast (as it should be) If so, how
Thanks.
Bernd. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Outlook Automation Hi, I want to know that if i create an Outlook Addin, how do i make sure that it is loaded eveytime i open Outlook Lets assume that i have PIAs and eveything required installed. The problem occurs when the Outlook object is opened by an Outlook Automation e.g. Active Sync. In that case, no toolbar is loaded. Is there any way i can make sure that my toolbar is always there
Regards
Kulvinder Singh Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Can anyone help me plzzzz? Hi dears I have some trouble with Office (Excel) Interop integration ... I have some applications and they are written in C# 2005 and some of them use excel Interop. The applications is not running in the global server when uploading..but it is working properly in my system..please help me..im having excel11.000 assembly in server and in my system also but it is not working in global server..but working here.. This Error message im getting.. Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
Line 28: double j, ao = 0, ao1 = 0, f = 0, pf = 0, f1 = 0, sum1 = 0, pf1 = 0, smin = 0, smin1 = 0, smin2 = 0, spnd = 0, yrts;
Line 29: object oMissing = System.Reflection.Missing.Value;
Line 30: Excel.ApplicationClass xlApplication = new Excel.ApplicationClass();
Line 31:
Line 32: SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
this is the error line wat to do..give me a solution plzzzzzzzzzz..
Regards
Zenith Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
set selection on mail item Hi,
I'm using vsto 2005, c#, OL-2003
Is it possible to se t selection on mail item in Outlook explorer, by entryID Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Passing parameters programmatically from VB.NET to Word Application.Run command Hi,
I have a question regarding writing Word VBA code with a VB.NET application. I am wondering if it is possible to pass parameters to the Application.Run command in an array, similar to the way it is done in PowerPoint VBA, rather than in a list.
I would like to set up something like this within my VB.NET application so that this single block of code can be used to automate the production of documents from many different templates :
Dim wdApp as Object
Dim TemplatePath as String
Dim MyMacro as String
Dim ParameterArray(30) as String
TemplatePath = file path to Word template to use
MyMacro = name of the macro to run
ParameterArray(0) = argument1
ParameterArray(1) = argument2
.
.
.
ParameterArray(n) = argumentn
wdApp = CreateObject( "word.application" )
wdApp.Documents.Add(TemplatePath, False , 0)
wdApp.run(MyMacro, ParameterArray)
Is there any other way of doing this When I tried the above, I got the following error message:
"Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."
Thanks very much for your help.
Chris. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Outlook Message Icon I have seen a few applications who place messages in outlook inbox with a more or less costum system icon instead of the normal mail/task/calendar icons.
Do any know on how to change those icons I am looking for a way to insert system messages from an application into Outlook, but need a way to change the icon at the same time.
Cheers, Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Trap save event in application level add-ins From an application level add-in, can I make sure that this is attached to every document created / opened
From my add-in startup event I attach as follows:
private void ThisAddIn_Startup( object sender, System. EventArgs e)
{
this .Application.DocumentOpen += new Microsoft.Office.Interop.Word. ApplicationEvents4_DocumentOpenEventHandler (Application_DocumentOpen);
}
Note the use of the ApplicationEvents4 (not supposed to be used by end user code! ). There is no event at this level for DocumentCreate.
And then in the event handler I CAST the document to the Tools namespace and attach the BeforeSave event....
// Attach beforesave to each document
void Application_DocumentOpen(Microsoft.Office.Interop.Word. Document doc)
{
((Microsoft.Office.Tools.Word. Document )doc).BeforeSave += new SaveEventHandler (ThisAddIn_BeforeSave);
}
Nasty code for something that should be quite simple Anyone know what I'm missing
Ken Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Word document author Hi all, I was wondering if it's possible to get the word document author programatically the same way as you can get the document name with: Selection. Document .FullName Any help much appreciated! Radu. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
DOCVARIABLES and specials characteres Hi all, I'm using DOCVARIABLES (Word.Variables) and I need to set name of those variables using spaces. It seems Word won't insert variables spaces. In place, it display something like "Error, no variable giving by the document" ("Erreur ! Aucune variable de document fournie" in french). If someone has a idea to do this... Thanks in advance, TSalm Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Apply decmial numbers to Excel Ranges Hi, I've a very basic problem on applying decimal numbers on Excel Ranges. Right now, I'm doing this like this:
Code Snippet
Excel.Range someRange;
someRange.Value2 = "1234"; This works fine. But if I've a decimal number, it doesn't work. I've tried several possibilities:
Code Snippet
someRange.Value2 = "1234.45"; someRange.Value2 = "1234,56"; // Because I'm using a german Office Version. decimal d = 1234.56; someRange.Value2 = d; No matter which version I'm using, the number appears in the Cell - so far so good. But Excel doesn't recognize it as a number but as a string - e.g. it is put to the left instead of the right. I'm using the following numberformat for the range:
Code Snippet
someRange.NumberFormat = "#,###,###.00"; Any hints for me Yours Volker Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Delete Outlook MailItem? Hello everyone,
I'm developing Outlook 2003 addin.
I'm using a copy of MailItem temporarily which I need to delete later.
I can do that by calling MailItem.Delete() method.
When I invoke Delete() method, Outlook stores it in 'Deleted Items' folder .
I would like to delete MailItem without Outlook storing it to 'Deleted Items' folder (like Shift+Delete).
Is this possible
Thanks. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
NEW Fix for VSTO SE Addins for Office 2003 and Vista FIX: Add-ins that are created by using Visual Studio 2005 Tools for the Microsoft Office System Second Edition do not run in Office 2003 Professional on a Windows Vista-based computer
SYMPTOMS
On a Windows Vista-based computer, add-ins that are created by using Microsoft Visual Studio 2005 Tools for the Microsoft Office System Second Edition (VSTO 2005 SE) do not run in Microsoft Office 2003 Professional when you try to debug one of these add-ins in Visual Studio 2005.
RESOLUTION
A supported update is now available from Microsoft. This update improves Windows Vista support for VSTO 2005 SE. This support enables you to run and to debug add-ins for Microsoft Office 2003 Professional by using VSTO 2005 SE in Windows Vista.
Read the full Knowledge Base article and download the Fix from MSDN here:
http://support.microsoft.com/kb/937652 Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
COM addin adds over 10 seconds to Microsoft Word startup time I built an extensibility addin using the wizard in VS-2003 for Microsoft Word. When installed, it adds over 10 seconds to Word's startup time. Does anyone have any ideas on why this is happening The Excel addin I created does not have this problem.
The delay appears to come before the OnConnection sub is called. CPU usage is 0% during this delay. Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Detaching VSTO customization Hello,
I have a Word 2003 document with VSTO customization. I want to be able to save this document with VSTO customization to a separate folder where the associated VSTO dll does not exist. When opening this newly saved document, I receive the 'Customization assembly could not be found..." message. I need to be able to strip away the VSTO customization from this document so the document is just a plain old Word document and not a VSTO Word document. Does anyone know how to do this
Steve P Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
API to retrieve Address from outlook address book? Hi, Can any one guide me or provide the link to retrieve Address from outllok address book Thanks in Advance Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Is it possible?? Hi, How could I uninstall my add-in that created button MyButton" in the outlook 2003 toolbar from MyButton event clicked Is it possible to reset toolbar I did in vs.net 2003 code:
Code Snippet
OnToolbarButtonClick(CommandBarButton cmdBarbutton,ref bool cancel) { Microsoft.Office.Interop.Outlook.Application applicationObject.ActiveExplorer().CommandBars["Standard"].Reset();
///I want to add uninstall this add-in.. }
Thanking you in anticipation! Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Adding InfoPath Form as Mail Attachment Hello, I try to add an InfoPath form as a mail attachment with vsto. I create my mail with this code : Outlook.Application outlook = new Outlook.ApplicationClass(); Outlook.MailItem Email = (Outlook.MailItem)outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); Then I try : Email.attachments.add() but : 1) I don't know how to get the form. Should I use thisXdocument 2) what arguments should I use in the method add (object Source, object Type, object Position, object DisplayName) I simply tried with Email.Attachments.Add("test", Outlook.OlAttachmentType.olByValue, 1, "attachment"); but I get the following error : L'exception System.Runtime.InteropServices.COMException n'a pas ete geree par le code utilisateur Message="Impossible de trouver ce fichier. Verifiez que le chemin d'acces et le nom du fichier sont corrects." Source="Microsoft Office Outlook" ErrorCode=-1905852414 StackTrace: a Microsoft.Office.Interop.Outlook.Attachments.Add(Object Source, Object Type, Object Position, Object DisplayName) a InfoPathProject2.InfoPathProject2.CTRL1_5_OnClick(DocActionEvent e) a Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent) Thank you for your help :D Kype Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Deployed Excel Add-in doesn't load The below I pasted from my upload on http://www.microsoft.com/office/community/en-us/default.mspx dg=microsoft.public.excel.programming&mid=1d13e6bc-4cc9-41ae-9744-2b32bc20a267 As this is the first VSTO-Office Add-in I try to deploy I haven't a clue why things doesn't work. The Add-In does install into the directory I expected, but simply doesn't load into Excel! (I see now a thread "Mysterious Add-in load issue" popping up, so sorry if this duplicates that thread) ADDITION I tried the suggested http://download.microsoft.com/download/b/6/7/b6711d3b-b509-4567-8599-98bf3473310f/vs2005-kb908002-enu-x86.exe solution mentioned in that thread however at this moment things seems to remain the same as it was! (perhaps since I'm using office 2007 in stead of 2003! , I'll experiment somewhat further with this!!!!) ======== FURTHER EXPERIENCE After restart of my developmentpc the Excel Add-in worked, however the Add-in setup Bolts crying the need for: KB908002\extensibilityMSM.msi KB908002\lockbackRegKey.msi KB908002\office2003-kb907417sfxcab-ENU.exe Read the need to add a seperate directory to the location of the setup, after this the setup worked on the targeted USER-machine However attempts to load the Add-in still gave the loading problem! ======= APOLOGIES with appologies for this scrappy contribution, it turned out that the above version that "worked" was the compiled, which had to be manually removed. after done thus and reinstall the add-in, also on this development machine the add-in DID NOT load. So back to where I was at the situation described below, on both development and user pc's. END ADDITION I wrote an excel 2007 add-in with C# using VSTO and VS 2005.
The add in works fine when started from VS 2005 so I sought to deploy.
The manifest reads:
<assembly xmlns="urn chemas-microsoft-com:asm.v1"
xmlns:asmv2="urn chemas-microsoft-com:asm.v2" manifestVersion="1.0">
<assemblyIdentity name="WinPrefabExcelPane.dll" version="1.0.0.0" />
<asmv2:entryPoint name="Startup" dependencyName="dependency0">
<asmv2:clrClassInvocation class="WinPrefabExcelPane.ThisAddIn" />
</asmv2:entryPoint>
<asmv2 ependency asmv2:name="dependency0">
<asmv2 ependentAssembly>
<assemblyIdentity name="WinPrefabExcelPane" version="1.0.0.0"
publicKeyToken="67511199162933c1" />
</asmv2 ependentAssembly>
<asmv2:installFrom codebase="WinPrefabExcelPane.dll" />
</asmv2 ependency>
</assembly>
Trying to load this installed version however I get after trying to load
this "COM Add-in" the message:
Load Behaviour: Not loaded. A runtime error occurred during the loading of
the Com Add-in.
this is the first Add-in I try to deploy in this manner, so I currently have
no clue of what is wrong here. The location of the manifest is as expected,
but something seems to be missing.
As said, starting from VS the add-in works fine.
Please help. Problem doesn't seem to be whether or not VS8 is installed.
also on this development machine, the installed version of my Excell 2007
add-in doesn't work. When started from my main program from where my users
are supposed to start Excel from.
Using the installed add-in when program starts from VS8 is an option I might
look into.
Strangly enough, starting the "mainprogram" from the release directory
wherein it is compiled and starting Excell the Add-in loads ! However this
seems to be the compiled version of the Add-in and not the installed
version!
I haven't a clue where the programs (Excell ( )) would obtain the
information to start the compiled Add-in!
Just some more information on the problem. VSTO / Office people might have
some idea. I'm a programmer in a production environment and the system should
be up and running asap, currently no user (without VS8) can even test the
system!
curious oddity.
Excell 2007 add-ins seem to be centering around .manifest files.
the "COM Add-in" interface of Excel 2007 one can Remove the installed (it
seems)
Add-in however for some peculiar reason the Add option does not offer the
option to reinstall a .manifest file (exe and dll are opted to search for).
The only way to reobtain the .manifest in the listed options is to
reinstall, which as said doesn't work.
So there is no way to try the version in my compiled directory this way.
Copying two .pdb files (from the compile release directory) into the
install-directory doesn't seem to help, didn't think so but heh at this point
I'll try anything.
Information anywhere about these .manifest files is curiously low, save some
listings in the two books. (I reckon since things ain't working as they
should!) Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Outlook 2007 Web Browsing Add-in I am trying to develop an add-in for Outlook 2007 which is essentially a web browsing add-in. The basic workflow is:
1. Select a folder listed under Inbox\Mail Folders
2. A list of websites appear as mail items would
3. Select one of the mail items to pull up the site in the right frame
The purpose of this is to be able to navigate a portal system from within Outlook. It seems pretty straightforward to me but so far I've ran into a couple roadblocks. First, it seems that the WebViewURL property only exists on Folders, not on MailItems. Secondly, the only method I can find to open an HTML page from a MailItem seems to only work with HTML files saved locally, not with URLs.
As an alternative, I would be happy with having the "websites" be represented by additional folders and just using the WebViewURL property, but I don't think I can change the icon to something that doesn't resemble a folder in some way. Also, I don't think you can change the way the folders are sorted -- they are always alphabetical.
I assume that it's possible to do what I need to do, but my experience with VSTO is limited to just this project. I am hoping that someone here can lead me in the right direction... I'm not looking for a complete solution... just any suggestions that may help me get there.
Thanks,
Ryan Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Binding Repeating Nodes to a Database in Word Can anyone inform me of some best practices on how to bind repeating XMLNodes to a dataset I just want to be able to display a field in a database inside of XMLNodes mapped into my document. Some of these may be variable in amount depending on the amount of rows returned. The XMLNode host control is easily bound but what options are available to bind data to repeating nodes Do I have to manually navigate the document structure and fill in XMLNode.Range.Text or what Thanks, Jake Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Problem with installation Hello, I have problem with Tools for Office SE. When I try to create some project in Visual Studio with Tools for Office I get message, that I should install 2003 with SP1. I was doing: 1. I had office 2003, I upgraded to 2007 trial, but Visio and FrontPage was not upgraded. 2. I removed trial and bought and installed full version of 2007 also without Visio and FP. 3.I tried few times reinstall Tools for Office SE but it did't help. 4. I removed all 2003 products and again reinstall Tools for Office but also didn't help 5.I installed PrimaryInteropAssembly for Office 2007 but unfortunatly didn't help. Please very much help me Thank you a lot and best regards, Milosz Kukla Tag: Visual Studio Tools for Office Publish custom forms programmatically Office
Rama Krishna rao
I have a requirement where I need to Publish the custom forms (.oft) programmatically. Any idea how to achieve this Code snippet would help.
Re: Visual Studio Tools for Office Publish custom forms programmatically
Sue Mosher - Outlook MVP
Use the Application.CreateItemFromTemplate to create a new item using the .oft file. Then use that item's FormDescription.PublishForm method to publish the form. See http://www.outlookcode.com/d/distributeforms.htm