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

Word document close event for the very first new document

$
0
0

Hi,

when Word starts it creates a new document, named Document1. Is there a way to get notified that Document1 is closed? The following event fires not for the first new document:

((Word.DocumentEvents2_Event)this.document).Close -=

new Word.DocumentEvents2_CloseEventHandler(this.Document_CloseEvent);


That event is fired for all the other documents. I really need to get notified by this event for Document1. How?

Yavuz


Excel cannot recover focus through taskbar when a modal form is being showed

$
0
0

We are developing an Excel 2007 Addin which consists mainly in a ribbon and some forms.

All the forms are modal and have the property ShowInTaskbar = False. In some computers, if you open one of those forms and then you give focus to another application, then you can't return to Excel through the taskbar. When the Excel button in taskbar is pressed, it looks pressed as usual but Excel is not brought to front. The only way to bring it to front is using ALT+TAB.

So far, this issue does occur in one machine running Windows Vista x32 and doesn't occur in two machines running Windows 7 x64.

Have you ever deal with this issue and found a solution?

Thanks in advance

How save a VSTO Excel as another naming

$
0
0

Hi,

I'm using VSTO with C# and Word2010 to create a Document-Level Customization Excel file. And the workbook let user to download data from database; formats and formulas are applied in the cells.

Now I wan to save those downloaded data (the whole excel workbook) as another naming, and I tried, some of the worksheets are not saving correctly. Is there anyway to save/copy the VSTO workbooks as a new workbooks and keeping all the formulas like a macro file? I even tried to manually copy few rows with formulas applied from VSTO worksheets to new workbook, but it's only copy the value but not the formulas behind..

Please advice..

Thanks!


In C# what is equivalent to the "Application.text()" method in VB ?

$
0
0

Hi friends,

The following code is written  in VB:

xlApp.Text(Round(myNum, 2), "[DBnum2]")     ' the "xlApp" is an application object for Excel

if myString=xlApp.Text(15284125.35, "[DBnum2]") ,then the result of myString is "壹仟伍佰贰拾捌万肆仟壹佰贰拾伍.叁伍".

Now, i want to rewrite the above code in C#, but i don't know in C# what is equivalent to  the "xlApp.Text()" method?

So, i hope your help, thank you!



ListObject bound to DataTable with DateTime column shows 41654 when 2014-01-15 entered

$
0
0

I have a Document level project that has a Dataset generated by Dataset Designer.  This dataset has a DateTime column.  A ListObject hast been created on a worksheet by dragging the DataTable from the DataSource window onto the worksheet. When I edit the cell bound to the DateTime DataTable column with '2014-01-15' it shows 41654.  I have tried to enter other input formats like 01-01-2014 and 41640 shows in the cell after pressing <ENTER>. How can I change it so that does not change what I entered? 

VSTO VS 2010 Excel 2007 - random replace formula with value?

$
0
0

This one has me scratching my head.

We have a billing template, with multiple worksheets in the workbook.  The add-in pulls data from specific places and puts it into an XML schema for use elsewhere.  It works great - except

We have a shipping tab, where zipcode and qty for that zipcode are entered... this is for sales tax calculations. The definition of the range is 

=Shipping!$B$2:$B$65536

the app starts at B2, and looks for a value, if it finds it, it then looks to the value in C2, and IF it has a valid entry, then it writes a record to a List of those records.

code :

      For Each cell In ShippingRange.Cells
        GetShippingInfo(cell)
      Next

the GetShippingInfo checks the values and either does or does not create the list item based on the validity of the data in the cell passed in.  

Most workbooks contain between 1 and 25 entries, but we are aware that there are some (direct mail, for example) where the number of entries will be quite large.

apparently, when the number gets to about 548, Excel loses its mind, and changes the formula in a cell on another worksheet (in the same workbook) to the value... like a copy/paste value

except that this is the only time it does it, and the code line where the break actually occurs is just reading from an entirely different cell on the Shipping Worksheet...

Is there some undocumented limitation somewhere that I'm obviously not aware of?

We tried breaking it up into multiple iterations of 500 rows at a time.  That pushed the error out to about row 570, but this is still not acceptable.

Help?

The final possibility I've come up with, I don't exactly know how to do.  I'd like to just close the workbook without saving changes, and without bringing up the 'do you want to save changes?' dialog box.  If you know how to do that, I'll take that as a solution, as then the formula would still be in place, as at this point, the application does not need to save the file.

Thanks for your help.

Clearing Cells

$
0
0

I need to clear 4 cells, I know I can do it like this, but is there a more efficient way of doing such?

Excel.Range xlRange1;
Excel.Range xlRange2;
Excel.Range xlRange3;
Excel.Range xlRange4;

xlRange1 = oWS.get_Range("B3", "B3");
xlRange1.Clear();
xlRange2 = oWS.get_Range("D4", "D4");
xlRange2.Clear();
xlRange3 = oWS.get_Range("L15", "L15");
xlRange3.Clear();
xlRange4 = oWS.get_Rage("Z42", "Z42");
xlRange4.Clear();

PowerPoint Slides with pictures !

$
0
0

I need to create a power point presentation with lots of slides  with 10-12 pictures each but later in future if i delete one picture in the middle then i will have to arrange all pictures again to get rid of blank space . I have to keep those pictures in the slide using priority list , is there a way to automatically  update slides once i delete picture in the middle?

Thanks so much for your help.

Sonia


Why VS2013 requires one way upgrade for Word 2010 add-in?

$
0
0

Windows 7 x64, VS2013 full install (with update 1 and latest march 2014 VSTO tools update).

However, office not installed.

  • Create new Word 2010 add-in.
  • Target .NET 4.0
  • Build the project.
  • Close the solution. 
  • Re-open same solution - now Visual studio says it requires to 1-way upgrade the add-in project. Why?

Ok, don't upgrade it. Now, install Office 2010 (install only Word 2010 enough).

Re-open same solution again - but now VS behaves well and does not ask for upgrade of the project.

Why it ask for 1-way upgrade of the project when office was not installed? Did I miss something? Or this is VS2013 bug?



Autoscale ribbon bar controls using Visual Designer

$
0
0

I am using code to generate button on my custom ribbon panel by array ,here is the code line,for defining the size of the button

this.buttonArray[NumberOfButtons].ControlSize=Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeRegular;

if I use 'regular' size it comes as small,if i use 'large' it will be large,but i want it to be dynamic as other outlook buttons on ribbon,when window size is decreased it should become regular size,and on maximized window they should come as large.

Through xml Designer we can define autoscale="true",butis this possible through code (Visual Designer)

Ribbon Commands: can we tell if a KeyTip was used on repurposed command?

$
0
0

I may actually be required to differentiate between when a ribbon element is simply clicked, or when a KeyTip was used.  Is there anyway to do that?  

A quick list of things I know how to do:

1) "repurpose" ribbon commands with XML <command> elements, and a onAction method.

2) Use Windows message Hooks to track keyboard input.

I would like for, for example, the onAction method, which currently gets called whether the ribbon element was clicked, OR a KeyTip was used, to differentiate between the two.  Perhaps the "Context" argument that is passed to the onAction method can help (it's not really well documented)?  Or, maybe I can reroute the KeyTip to a different method, somehow.  Whatever is necessary to process them differently.

I would like to know if there is any KeyTip-specific functionality that I am missing, that may serve as another option.

Thank you!

vsto project publish error

$
0
0

i have a word addin project, the main project has reference a exe assembly, in debug mode vs2013 work perfect, but after i publish the project, when run the installer, there will be a error dialog stop the process.

i think this is a bug, i don't do anything, just follow the standard steps.

VS 2012, Word 2013 - You Are Currently Viewing this document in multiple windows.

$
0
0

When running the code below, I receive an error:

You are currently viewing this document in multiple windows.  To attach an XML Expansion pack, you must first close all additional windows so that you are view the document in only one window.

I've pinned the cause of the error to the line:

Globals.ThisDocument.ActionsPane.Show()

I am waiting for a short period of time before calling the show.  I have found that if I change the wait to 60 seconds, the code works fine.  Obviously, I can't make a user wait for a minute between transactions.  I've fiddled with the wait timer, 30 seconds isn't enough, 45 seconds is hit or miss.  This project, and exact same code worked fine in VS 2008, VS 2010, and with office 2007 and 2010.  The code also runs fine with VS 2012 and office 2010, but when I switch to office 2013, the problem starts.  Everyone in our organization is using office 2013, so it's not an option to not use it.

 'First remove the actionspane.
        Globals.ThisDocument.ActionsPane.Clear()
        Globals.ThisDocument.RemoveCustomization()
        Globals.ThisDocument.XMLSchemaReferences("ActionsPane").Delete()
        'Then save the document to the local machine without the actionspane
        Dim strfilename As String = My.Computer.FileSystem.GetTempFileName & extension   'Me.FullPath & extension
        Globals.ThisDocument.SaveAs(strfilename)

        'Also save a tmp file for the user.
        Dim strTempFile As String = My.Computer.FileSystem.GetTempFileName & extension
        Globals.ThisDocument.SaveAs(strTempFile)
        System.Windows.Forms.Application.DoEvents()
        If My.Computer.FileSystem.FileExists(strfilename) Then
            Try
                Me.ImageFileName = "MM-" & System.Guid.NewGuid.ToString
                Dim strNewFileName As String = Me.FullPath & extension
                FileCopy(strfilename, strNewFileName)

                System.Windows.Forms.Application.DoEvents()
            Catch ex As Exception

                MsgBox(ex.ToString)
            End Try
        End If

        'Finally, wait a few second before proceeding to make sure all this stuff in the file system
        'completes before we continue. Otherwise Imaging may try to sweep up the file before it is unlocked
        'or the customizations are removed.
        System.Threading.Thread.Sleep(4000)
        'All the doevents ensure other tasks get the right cycles to complete.

        'Now, show the customizations again so the user can continue.
        Try
            Globals.ThisDocument.ActionsPane.Show()

            System.Windows.Forms.Application.DoEvents()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

Rob Dale

Need help in getting all shared calenders..

$
0
0

Hi,

When we are the delegate for a person, we are able to access their calender.
I would like to do the same, and need to attach an even to Item Add.

How to get hold of all the calenders??

I know about...
Application.GetNamespace(LmoConstants.Mapi).GetSharedDefaultFolder(Recipient,9)

But I need to get hold of the calenders without knowing the recipient.

Is there any way to do this?
Or a way to know who all have shared their calender with Us.. 

Regards,
Arjun


--Arjun (-|-)ZzzzZZzzz ...

open msword in vs.net

$
0
0

hi friends

please help me : i need to open msword document in visual studio c#

that data stored to richtextbox, i need to store chemical formula like so2 h2O format to store in richtextbox please help me

my email id kkarthikk005@gmail.com


Autolink for VSTO_Redist.exe

$
0
0

Could anyone please indicate the URL for the autolink to download the latest version of Visual Studio Tools for Office for Office versions: 2007/2010/2013.

AlBear


Albert

Outtlok AddIn not visible in Outlook when .msi is run.

$
0
0

I've created this Outlook button AddIn that needs to be displayed on the "Home" tab in Outlook.

Created this and also a setup project to be able to deploy the .msi files on to the client machines.

The issue Im facing is, when the setup project is "Built","Rebuilt" or "Install"ed the button appears in Outlook. If I run the XX.msi file or the setup.exe file, the button doesn't show up on the tab.

My OS is 32 bit and MSOffice is 32 bit as well. I have the registry setting in HKEY_USER. 

Also when I try modifying the prerequisites location to local in the Setup project, the "Build" action throws me a missing dotnetfx3.5Clientprofile.exe error for which I installed the client profile but in vain.

If this is unselected, and the project is built, I again see the AddIn in outlook. So In any case the Build or Install function works.

Any ideas?

Thanks.

Click-once publish addtional files

$
0
0

in my word addin project, the main project have a reference assembly which have some content file, these files should be publish, i have already set these file's build action to "Content" and "Copy always", but in the publish result these file is lost.

i have search a thread in stackoverflow 

Why doesn't ClickOnce in Visual Studio deploy content files from dependent assemblies?

but the solution is not workable for me.

how can i do?  thanks

my envirement:

vs2013 sp1, office2013, win8 x64

VSTO Excel 2007 Addin with SmartTags causes Excel to become unresponsive.

$
0
0

Facts;

Windows 7 x64 - Office 2007 - VSTO Com Add-in with SmartTags enabled.

Problem;

The problem is that intermittently upon opening Excel during the day Excel become unresponsive and eventually shows

"Microsoft Excel is waiting for another application to complete an OLE action"

The only way I can reliably hope for this error to happen is by opening 2 files from Windows Explorer. Normally the second time I open the second file this error will happen.  So the steps to make this error are

  1. Open 2 files 1 after the other.
  2. Close both files.
  3. Open the same two files one after the other. 
  4. Upon clicking on the second file Excel opens and is immediately unresponsive.
  5. Some time later it will show this message and clicking OK does not help.

Cause Reduction;

All other excel addins have been made inactive.

Tests;

  1. If I have a blank addin with only startup and shutdown methods with no code - there is no error.
  2. If I have my addin with all code loading but turn off VSTO Recognizers - there is no error.

Conclusion;

My addin code itself is not causing any problems however the VSTO Recognizer is either not unloading properly each time Excel closes or is not loading properly each time it is loading.

Here is the code. Once again this code and addin works fine if VSTO Recognier is disabled.  As soon as I enable the Recognizer I get the problem.

Private Sub ThisAddIn_Startup() Handles Me.Startup

        Dim smartTagFile As Microsoft.Office.Tools.Excel.SmartTag = Globals.Factory.CreateSmartTag("MYApp#MYApp_File_Smart_Tag", "MYApp File")

        smartTagFile.Expressions.Add(New Regex("(?<![A-Z\d])(?:(?:19|20)?\d\d[A-Z]\d{5}((\s\s?(?!WO|WE|EP)[A-Z]{2}(?![A-Z]{2})|(?:WO|WE|EP)[A-Z]{2}|(?:WO|WE|EP|[A-Z]{2}))(0[1-9]|1[0-5])?)?|(?:19|20)\d{7})(?!\d)"))


        IpasAkzAction = Globals.Factory.CreateAction("File Lookup.")

        smartTagFile.Actions = New Microsoft.Office.Tools.Excel.Action() {IpasAkzAction}

        Me.VstoSmartTags.Add(smartTagFile)

    End Sub

 Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

end sub

SQL Connection to Excel 2010 table

$
0
0

Having an Excel 2010 workbook (c:\Users\myID\LocalData\myFile.xlsm) which contains an excel table ("CR_Model" within tab "CR"). Name manager shows my Name for this table as CR_Model. Trying to query this excel table from C# via an SQL query using following connection:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\myID\LocalData\myFile.xlsm;Extended Properties="Excel 12.0 Macro;HDR=YES";

SQL Query: SELECT * FROM CR_Model;

Error: Microsoft Access database engine could not find the object 'CR_Model'.

Any idea how to reference an excel table object from SQL ?

Thanks


Tomy


Viewing all 5157 articles
Browse latest View live


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