Quantcast
Channel: Visual Studio Tools for Office (VSTO) forum
Viewing all 5157 articles
Browse latest View live

Hide entire ContentControl

$
0
0

Hi,

I have a very simple requirement. I need to hide an entire contentcontrol in ms-word 2007 by using interop in a word-addin 2007 project (c# 4.0 and Visual Studio 2010).

I am iterating all ContentControls in the document by using document.ContentControls. I want each ContentControl to be hidden. I am using the following code:

contentControl.Range.Font.Hidden = 1;

But this only affects the content of the ContentControl.

In word I am able to do this by first selecting the entire contentControl (clicking on the grip) and set the font to hidden. Is there a possibility to do the same in interop?

Regards,
Koray


F/\nt/\sy PRODUCTIONS


Change language in OfficeRibbon causes the designer to throw exception

$
0
0

After i select another language then "Default" under properties of the OfficeRibbon, i get the following exception and the designer is unable to show the UI:

The type 'Microsoft.VisualStudio.Tools.Office.Ribbon.View.GenericRibbonView' has no property named 'Factory'.

How can i resolve this problem?

Im using microsoft visual studio 2010 ultimate

Thanks for the reply

Migrating Visual Studio Projects across computers with different versions of office installed

$
0
0

Hi

I created a word 2007 com addin using visual studio 2010 and office 2007 was installed on the computer. I want to migrate the project onto another computer (because the computer is faster) and it has office 2010.

However when I bring the project into the other computer the conversion wizard wants to change the word addin to a 2010 (ie change the office pia reference from 12 to 14).

I know that I can create word 2007 solutions with office 12 reference on the computer that has office 2010 installed on it.

So what do I need to do so that visual studio does not convert my solution.

ActiveX wrappers issue with Excel 2010

$
0
0

Hi,

I am facing an issue with ActiveX wrappers which are used in Excel 2010 to display different UI components.

I am rendering number of controls in Excel workbook using VSTO addin. When I save the workbook, controls get deleted but the corresponding ActiveX wrappers get stored in the workbook.When I reopen the workbook and try to insert the controls again, it throws exception "Cannot insert object". 


Attachment contains a VSTO solution with workbook in which issue is reproducible. Following are the steps to reproduce the issue:
1. Extract and open the solution. Shared at http://1drv.ms/MraOEO
2. Run the solution. This will open the excel.
3. Open the attached file. Shared at http://1drv.ms/1eGVoCq (Extract and open it)

4. Click on "Insert Control" button. This will show an error.

This issue doesnt appear on every Save operation. It is coming randomly on saving and inserting control.

This issue is not reproducible with Excel 2007. Also, if I save the corrupted file on Excel 2007, it works fine on Excel 2010 as well. Seems like Excel 2010 makes some changes in the file which causes this issue.

      Please let me know if anyone has faced this issue or any idea about the issue.

Thanks & Regards,

Diptesh Raut.


Diptesh Raut.

Using ServerDocument class in asp.net web site

$
0
0

Hello!

I made a document-level add-in for Excel workbook and published it

In my web site i expect user to fill in some text in a form, and then in a button click handler i set this text into a cached property of a document.

It's all work fine on my machine, but when i deploy web site on my company's web server, it fails.

The question i want to ask is: what components (minimal requirements) should be installed on a server to let ServerDocument work properly? And is there a possibility to just put some assemblies into a bin folder of my web site rather than installing a software?

Used framework on the server is 3.5

Excel is still running though I quit and released the object

$
0
0

In my application I am generating an Excel report and saving it in a location using C# codes. Once I saved I am closing the Excel and quiting the Excel application by code and I am releasing the memory of the EXCEL as well. However, what ever I do, the instance of the EXCEL is still showing in the Task Manager until I completely close the whole application

This is my code

 

//This is how I am Opening Excel file

 Microsoft.Office.Interop.Excel.Application xlApp;
 Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
 Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
 xlApp = new Microsoft.Office.Interop.Excel.Application();//after genrating the report this is how I am Closing and quiting

 xlWorkBook.Close(true, misValue, misValue);
 xlApp.Quit();// Apart from I am releasing the Memory for Excel as follows

releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);

//This is the method for releasing objectprivatestaticvoid releaseObject(object obj)
    {try
      {
        System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
        obj = null;
      }catch (Exception ex)
      {
        obj = null;
      }finally
      {
        GC.Collect();
      }
    }

Although I close, quit and released the object, why still EXCEL is in running? If user generates reports 5 times, 5 instance of the Excel is running (can see them in the Task Manager).

Please help me..


Dreaming a world without any war in anywhere

Button on a Worksheet

$
0
0

Hi All,

I have created Command Button(with an image inside it) by following this blog, it's working perfectly fine. My button looks like this :  

but I want it to look exactly like this: 

So this is my problem Is there any way I can format it like my desired outcome. There is nothing in it's properties that I can for work with. 

Thanks,


Attiqe Ur Rehman

Actual start Coding - If tsk.ActualStart > projApp.ActiveProject.CurrentDate Then

$
0
0

Addin which I am trying to develop in MSProject 2010 for identifying number of tasks where the Future date is erroneously entered in the Actual start for the Tasks. But when I try the code mentioned below it gives me an error the source type is not convertible to the destination type. (8th line in the code). The same code works fine in project VBA.

Public ActStFut AsInteger   

Public Sub Actual_Start_in_Future()

       ActStFut = 0

       For Each tsk In projApp.ActiveProject.Tasks

           If Not tsk Is Nothing Then    'Test for blank row

               If Not tsk.Summary Then

                   '   If tsk.ActualStart <> "NA" Then

                   If tsk.ActualStart > projApp.ActiveProject.CurrentDate Then

                       ActStFut = ActStFut + 1

                   End If

                   ' End If

               End If

           End If

       Next tsk

   End Sub

Thanks in advance for the help.

Rameshchandra C Keni (PMP)


RCKeni


VS 2010 .NET Framework 4.0 C# - Outlook 2010 Add-In - Filtering Sent Items folder of IMAP Account Crashes Outlook

$
0
0

Hi

I've created a small add-in for Outlook 2010 using Microsoft Visual Studio 2010, .NET Framework 4.0 and C#

Add-in consist of a ribbon and a button on the ribbon. On click of the button, it will apply a filter on the current view of the explorer to filter all the mails that are received in last 10 days.

When i tried this add-in with my Gmail (IMAP) Account Inbox folder, it worked fine. When i tried the same with the Sent Item folder of my Gmail, outlook itself got crashed.

Any idea why this is happening?. The crash is happening exactly in the code the view.Apply() method is being invoked.

This issue is not occurring for an Microsoft Exchange account.

Code inside Button click event on the Ribbon (Ribbon1.cs)

private Outlook.Explorer _activeExplorer = null;

_activeExplorer = ThisAddIn.ActiveExplorer;

string datePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
string timePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;

string dateString = DateTime.Now.AddDays(-10).ToUniversalTime().ToString(datePattern + " " + timePattern);
string filterString = "\"urn:schemas:httpmail:{0}\" >= '" + dateString + "'";

   if (_activeExplorer != null)
            {
                Outlook.View newView = null;
                if (!String.IsNullOrEmpty(filterString))
                {
                    string fieldName = "";
                    if (_activeExplorer.CurrentFolder.Name.ToLower().IndexOf("sent") >= 0)
                    {
                        fieldName = "date"; //Filter based on Sent date
                    }
                    else
                    {
                        fieldName = "datereceived"; //Filter based on received date
                    }
                    filterString = string.Format(filterString, fieldName);
                }

                newView = _activeExplorer.CurrentView; //Getting the current View from the explorer object.

                if (newView != null)
                {
                    newView.Filter = filterString; //Setting the filter string
                    newView.Apply();

                    Outlook.TableView tblCurrView = newView as Outlook.TableView;
                    if (tblCurrView != null)
                    {
                        Outlook.Table viewTable = tblCurrView.GetTable();
                        if (viewTable != null)
                        {
                            int itemsFound = viewTable.GetRowCount();
                            label1.Label = itemsFound + " mails";
                            viewTable = null;
                        }
                        tblCurrView = null;
                    }
                    newView = null;
                }
            }

Working Passthrough in Access, doesn't work in VB6?

$
0
0

Hey hey

Pretty sure I've got all the right references etc, but the following works in Access <acronym style="border-width:0px 0px 1px;border-bottom-style:dotted;border-bottom-color:#000000;cursor:help;color:#333333;font-family:Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif;font-size:13px;line-height:normal;background-color:#fafafa;" title="visual basic for applications">VBA</acronym>:

Code:
Sub TestDump()

Dim db as Database
Dim LPT as QueryDef, tblDef as TableDef
Dim DStmp as string, connstr as String

DStmp = Cstr(Format(Now(), "yyyymmdd"))

Set db = DBEngine.CreateDatabase("C:\Users\climoc\Desktop\" & DStmp, dbLangGeneral)
Set tblDef = db.CreateTableDef(DStmp)

With tblDef
.Fields.Append .CreateField("FIELD1", dbText)
.Fields.Append .CreateField("FIELD2", dbText)
End with

db.TableDefs.Appen(tblDef)

Set LPT = db.CreateQueryDef("qryTmp7")

connstr = "ODBC;Driver={Microsoft ODBC for Oracle};Server=MYSRVR;uid=USER;pwd=A!B2C£"

With LPT
.Connect = newstr
.SQL = "SELECT FIELD1, FIELD2 FROM OraTbl WHERE FIELD2 = 'ATextValue'"
.ReturnsRecords = True
.Close
End With

db.Execute "INSERT INTO " & DStmp & "([FIELD1], [FIELD2]) SELECT qryTmp7.[FIELD1], qryTmp7.[FIELD2] FROM qryTmp7"

db.QueryDefs.Delete "qryTmp7"

End Sub

It works brilliantly.

But then when I move it into my VB6 module in Visual Studio, the following doesn't work (it doesn't throw an error or bug). It creates the database file and the table (and if I remove the 'QueryDefs.Delete "qryTmp7"' line at the end, the Query stays and looks fine too) - but no records are added to the table from the returned passThrough query.

Code:
Dim AccApp as new Microsoft.Office.Interop.Access.Application
Dim db as DAO.Database
Dim LTP as DAO.QueryDef, tblDef as DAO.TableDef
Dim DStmp as String, connstr as String

DStmp = Cstr(Format(Now(),"yyyymmdd"))

db = AccApp.DBEngine.CreateDatabase("C:\Users\climoc\Desktop\" & DStmp, Dao.LanuageConstants.dbLangGeneral)

tblDef = db.CreateTableDef(DStmp)

With tblDef
.Fields.Append(.CreateField("FIELD1",10))
.Fields.Append(.CreateField("FIELD2",10))
End with

db.TableDefs.Append(tblDef)
LPT = db.CreateQueryDef("qryTmp7")

connstr = "ODBC;Driver={Microsoft ODBC for Oracle};Server=MYSRVR;uid=USER;pwd=A!B2C£"

With LPT
.Connect() = newstr
.SQL = "SELECT FIELD1, FIELD2 FROM OraTbl WHERE FIELD2 = 'ATextValue'"
.ReturnsRecords() = True
.Close()
End With

db.Execute("INSERT INTO " & DStmp & "([FIELD1], [FIELD2]) SELECT qryTmp7.[FIELD1], qryTmp7.[FIELD2] FROM qryTmp7")

Anyone spot or know of anything tricky about doing DAO/Access style things from VB6?

I have since discovered that it has to be 

"Dim LPT as Microsoft.Office.Interop.Access.Dao.QueryDef", etc (same for the tableDef) - but still the same problem - creates database and table, doesn't append query results



Thanks
C

Apps deployed from a server with ClickOnce - they appear to be running from the server, not locally

$
0
0

Hello,

I've got an Outlook Add-In written with VS2012 Ultimate.  I'm using ClickOnce to publish it to a file share location.  We want our customers to navigate to that location, double-click the setup.exe file, and have it install on their machine.  We want the app to run locally, but check the share location for updates.  When I test this, it appears to install something locally, but the new registry entry for the add-in points to the server location.  It makes me think the add-in, after installation, is running from the server, rather than from the local machine.  Can anyone shed some light on this?  We want it to run locally, but check for updates at the server location.

I've found several answers that tell me it can be done, and how to do it, but the answer involves the 'Publish' tab having an option to make the application available offline as well as online.  In my version of VS2012, that option isn't there.  I've tried setting the Publish and Installation locations to various values (combo of server and local), but whenever I install it from the server, it always has the registry entry pointing to the server.  There is no such 'offline' option on that Publish tab, as they describe here, about halfway down the page, in the "To Publish To A Fileshare" section, item #5:

http://msdn.microsoft.com/en-us/library/31kztyey(v=vs.110).aspx

So it makes me wonder what the deal is - why don't I see that option? A lot of answers refer to it.  Or IS the application actually running locally, even though the registry entry points to the file share?  Perhaps I'm approaching this wrong, or assuming incorrectly that a 'fileshare' is the same as a location on the network that everyone can get to.  I'm installing it from this type of a location:  \\servername\folder\ 

Thanks for any insight you can provide.

Outlook 2010 - MAPI Headers

$
0
0

Hi,

I am using an Outlook 2010 addin using VS 2010 and C# and VC++ 2010 class libraries. My target is to deploy this to Outlook 2010 64 bit.

The VC++ project using mapi32.dll using DLL import in C# and a call to VC++ project. I am using methods like HrGetOneProp@12, HrSetOneProp@8 and MAPIFreeBuffer@4.

This works fine in Outlook 2010 32 bit but fails for Outlook 2010 64 bit saying the "Could not find entry point for HrGetOneProp@12 in mapi32.lib".

I did a search on net and it seems like that i have to download Outlook 2010 - MAPI headers which i did and the zip file has extracted 18 header files on my machine. My question is what should i do now ?

I have 3 versions of mapi32.lib file on my machine in Lib folder in Windows SDK. Should i replace all of these header files with the ones i downloaded ?

Do i need to do something else as well ?

Thanks


Kulvinder Singh

How to detect the excel is call by powerpoint?

$
0
0

Hi,

I have a VSTO add-in which will prompt user to input file setting (frm.ShowDialog()) when open or save file.  It normally work fine but I got a problem that when user add excel object into PowerPoint silde by ("Insert" -> "Object" -> Select from file -> select excel), the PowerPoint hang caused by waiting the answer of excel prompt but it does not load on screen.

So how can I detect the add-in is called by others application?  If I can know the excel is called by PowerPoint, then I can skip the setting prompt and let it run normally.

Thanks.


calendarw

Parent word document freezes when word document is produced from its addin

$
0
0

I have a word add in where it loads the web browser dialog which connects to share point site, from there i can select the custom templates which we have to create a word document. after it creates new word document it should close the dialog instead it is freezing the dialog also the parent word documents stops responding. The same behavior works well in IE and other addins(excel, powerpoint and outlook).

function SI_BIF_ProduceFile(strFileUrl) {
 debugger;
   var obj = new ActiveXObject('SharePoint.OpenDocuments.3');
   obj.EditDocument(strFileUrl);
}

The above is the code which generates the word document.

If anyone has any idea please suggest, looks like a know issue but i didn't find any solution yet.

Thanks in advance.

Multithreading in VSTO40 (PowerPoint add-in)

$
0
0

Hi,

I need to upload files in my PowerPoint addin on background thread, but I do not know, if and how is possible to correctly use threads and async calls in VSTO addin. When I tried to use threads in my addin (same as in common .NET apps), PowerPoint was crashing or I couldn't build project.  When I call my upload service (ot other long-time tasks) from main thread, PowerPoint GUI is blocked during uploading/processing. It is possible? If yas, can you past some example code, how to?

Thanks


Get Microsoft Project 2007 CustomDocumentProperties names and values

$
0
0

Hi, using Visual C# 2010 Express and MS Project 2007.

I am not using Visual Studio Tools for Office, but can read/write data to MS Project files using Visual Studio 2010 solution. However, I am unable to retrieve list of microsoft project file CustomDocumentProperties

I have reference:

using MSProject = Microsoft.Office.Interop.MSProject;

and code:

MSProject.Application projApp = new MSProject.Application(); projApp.FileOpen(<mppfile>, true);

MSProject.Project proj = projApp.ActiveProject;


For a known existing CustomDocumentProperty name I can retrieve value as:

string strDBName = proj.CustomDocumentProperties.Item("Databases").Value.ToString();


However, if I want to get list of all existing CustomDocumentProperty names and their values, how can I do that?

Either of the following lines:

Microsoft.Office.Core.DocumentProperties docProps = proj.CustomDocumentProperties;
Microsoft.Office.Core.DocumentProperties docProps =  (Microsoft.Office.Core.DocumentProperties)proj.CustomDocumentProperties;

throw exception:

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Core.DocumentProperties'. 
This operation failed because the QueryInterface call on the COM component for the interface with IID '{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error: 
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).



The following code:

System.Collections.Generic.List<string> list = proj.CustomDocumentProperties.Items.ToList();

throw exception:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:
'System.__ComObject' does not contain a definition for 'Items'   
at CallSite.Target(Closure , CallSite , ComObject )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)   
at CallSite.Target(Closure , CallSite , Object )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)

The following code for non-existing CustomPropertyName:

string strDBName = proj.CustomDocumentProperties.Item("BadValue").Value.ToString();

throws exception:

System.ArgumentException: Value does not fall within the expected range.   
at System.Dynamic.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)   
at CallSite.Target(Closure , CallSite , ComObject , String )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)   
at CallSite.Target(Closure , CallSite , Object , String )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)


I looked up the KB
How To Use Automation to Get and to Set Office Document Properties with Visual C# .NET
http://support.microsoft.com/kb/303296/en-us

but it only explains how to retrieve a known existing DocumentProperty or create one,
doesn't say how to get list of all existing DocumentProperty names and values

Thanks,

-srinivas y.


sri

Repaired my Office installation over 10 times now

$
0
0

I'm being tasked by our company for Visual Studio Office Solution development and i need to research which setup (VS + Microsoft Office) is best.

Our company currently has licensed 2007 and 2010 enterprise. The 2010 license is however, only for higher ranked officers with corporate email accounts so i suppose VS 2010 / VS 2008 + Office 2007 wins.

All i had is "Cannot open the workbook in designer, to fix the problem repair your installation of Office". I've repaired my Office installation over 10 times now including uninstalling everything for setting up my PC for Office Solutions but nothing seems to work and no, i am not running side-by-side installations of Microsoft Office.

I even compromised my setup, trying to install 2013, 2008, anything that has trial version on it, but so far only VS 2013 + Office 2013 works. Ironically 2013 is the only thing that is not going to be okay-ed by management because our company has over 10.000 employees and there's not a slightest chance they are going to purchase 2013 because the majority of the employees are still using 2007.

The only thing that i haven't done is to reinstall my Windows completely and come on Microsoft, if i were to go that far for Office Solution development what am i supposed to do when my coworkers jumped into the boat? Because we didn't just develop only Office Solution, we also need to setup the environment for other developments.

And also, my environment is 64 bit and the framework being used is 4.0

Get Microsoft Project 2010 CustomDocumentProperties names and values

$
0
0

Hi, using Visual C# 2010 Express and MS Project 2007 (and then tested with MS Project 2010 too).

I am not using Visual Studio Tools for Office, but can read/write data to MS Project files using Visual Studio 2010 solution. However, I am unable to retrieve list of microsoft project file CustomDocumentProperties

I have reference:

using MSProject = Microsoft.Office.Interop.MSProject;

and code:

MSProject.Application projApp = new MSProject.Application(); projApp.FileOpen(<mppfile>, true);

MSProject.Project proj = projApp.ActiveProject;


For a known existing CustomDocumentProperty name I can retrieve value as:

string strDBName = proj.CustomDocumentProperties.Item("Databases").Value.ToString();


However, if I want to get list of all existing CustomDocumentProperty names and their values, how can I do that?

Either of the following lines:

Microsoft.Office.Core.DocumentProperties docProps = proj.CustomDocumentProperties;
Microsoft.Office.Core.DocumentProperties docProps =  (Microsoft.Office.Core.DocumentProperties)proj.CustomDocumentProperties;

throw exception:

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Core.DocumentProperties'. 
This operation failed because the QueryInterface call on the COM component for the interface with IID '{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error: 
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).



The following code:

System.Collections.Generic.List<string> list = proj.CustomDocumentProperties.Items.ToList();

throw exception:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:
'System.__ComObject' does not contain a definition for 'Items'   
at CallSite.Target(Closure , CallSite , ComObject )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)   
at CallSite.Target(Closure , CallSite , Object )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)

The following code for non-existing CustomPropertyName:

string strDBName = proj.CustomDocumentProperties.Item("BadValue").Value.ToString();

throws exception:

System.ArgumentException: Value does not fall within the expected range.   
at System.Dynamic.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)   
at CallSite.Target(Closure , CallSite , ComObject , String )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)   
at CallSite.Target(Closure , CallSite , Object , String )   
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)


I looked up the KB
How To Use Automation to Get and to Set Office Document Properties with Visual C# .NET
http://support.microsoft.com/kb/303296/en-us

but it only explains how to retrieve a known existing DocumentProperty or create one,
doesn't say how to get list of all existing DocumentProperty names and values

Thanks,

-srinivas y.


sri


COMException - Exception from HRESULT: 0x800A03EC with Excel 2013 doing Merge

$
0
0

Ok, this is the second day navigating through this error with not exact solution found. I have the following code:

        Dim oRng As Excel.Range = objExcelSheet.Range("A1", ColumnLetter(intLastColumn) & "1")
        With oRng.Merge()            .Value2 = strCompanyTitle1
            .HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
            .Font.Bold = True
        End With

When the execution reach the .Merge() statement it throw the following COM Exception:

System.Runtime.InteropServices.COMException was unhandled
  ErrorCode=-2146827284
  Message="Exception from HRESULT: 0x800A03EC"
  Source=""
  StackTrace:
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Range.Merge(Object Across)
       at TrademarkApplication.TrademarkReportMenuForm.btnPrint_Click(Object sender, EventArgs e) in Z:\FXIT_PRJ\VB2005\Trademark_WeloSolution\TrademarkApplication\Forms\Trademarks\TrademarkReportMenuForm.vb:line 302
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at TrademarkApplication.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

I have tried working with the solution mentioned on:

http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15
http://blogs.msdn.com/b/eric_carter/archive/2005/06/15/429515.aspx
http://www.blogcoward.com/archive/2011/02/06/Excel-Interop-System-Runtime-InteropServices-COMException-Microsoft-Excel-cannot-access.aspx
http://social.msdn.microsoft.com/Forums/vstudio/en-US/675579a0-437b-4678-8078-c0be7695db10/comexception-exception-from-hresult-0x800a03ec?forum=vsto

But non of the links helped me to solve the problem. I have tested the Application where this code is with Excel 2010 and it work perfectly and never had problems the client was using Excel 2003 and 2007.

I hope anyone can help me out on this one.

Thanks in Advance,

How to disable macros in Excel from VB.Net

$
0
0

 

Hi All,

 

(I've posted this in CLR forum and did not get answer, hopefully someone here can help me)

 

I am now writing program to generate excels from a template file which contains marcos and I do not want the macros run when I access it through my program.

Is it possible to disable the macros from VB.Net (Window Forms) on opening the workbook or application?

I am using Microsoft.Office.Interop.Excel to do above development.

 

Please advise.

 

Thanks and Regards,

Cherry

Viewing all 5157 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>