DKUS007

I am using a window based application in .Net1.1(C#), where I am using Office 2003 PIA.

In this application I am caputuring Ctrl-V and doing pastespecial functionality of Excel. But after pasting I am not able to Undo or Redo to previous state.

Below are my code after capturing CTRL-V below code function I am executing

public void ExcelPaste()
{
try
{
IDataObject objPresumablyExcel = Clipboard.GetDataObject();
if (!(objPresumablyExcel == null))
{
if ((objPresumablyExcel.GetDataPresent(DataFormats.CommaSeparatedValue)))
{

Microsoft.Office.Interop.Excel.Worksheet TheSheet = null;
TheSheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.ActiveSheet;
object omissing=Missing.Value;
TheSheet.PasteSpecial("XML Spreadsheet", false,false,omissing,omissing,omissing,omissing);

}
}
else
{
MessageBox.Show("Clipboard is empty!");
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}

}

Please help me how can I handle the undo and redo functionality.

I tried with Application.Undo(). but it didn't help me. I need the same functionality as in Excel.

Thanks in advance.




Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

Dennis Wallentin

Hi,

If You need urgently help then I suggest that You're looking for a consultant to hire

The following link should get You started: Undoing a VBA subroutine






Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

DKUS007

Is there anyway to do in c#

I need some c# code






Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

Cindy Meister

Your question is definitely off-topic in this forum, as it's not related to VSTO 2.0 (for VS 2005).

You can try addressing your question to the office.developer newsgroups, as listed under the resources in the "Please Read First" message at the top of this forum. When you post, you need to specify HOW application.undo isn't accomplishing what you need. If what you want is functionality the object model doesn't provide, you may need to program your own "roll-back" facility. Possibly, the excel.programming newsgroup could help you, but you'll want to phrase your questions language-neutrally as the specialists there tend to be rather .NET-phobic...






Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

NSK

Even I am facing the same problem. After doing a paste special in Excel through code I am not able to undo to previous state.Any suggestions are welcome.



Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

DKUS007

Hi

This is an issule with Excel interop.

There are some work arround. I did the mmiac of "Paste Special" by

Excel.workbook.SendKeys

this may help you






Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

NSK

Could you please paste the code here. Thank you in advance.



Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

DKUS007

Here is the code

public void ExcelPaste()
{
try
{
IDataObject objPresumablyExcel = Clipboard.GetDataObject();
if (!(objPresumablyExcel == null))
{
if ((objPresumablyExcel.GetDataPresent(DataFormats.CommaSeparatedValue)))
{
workBook.Application.SendKeys("+{F10}SX{ENTER}",true);
System.Threading.Thread.Sleep(2000);
}
else
{
workBook.Application.SendKeys("^V",true);
System.Threading.Thread.Sleep(2000);
}
}

}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}






Re: Visual Studio Tools for Office Undo and Redo in Office automation in .Net 1.1--Urgent Help needed

parmanu

Hi,
I have tried the approach given in the above sample...
but i am getting flickering window for a fraction of second, which automatically on-off.
could any 1 plzz help me, How to get this momentry flickering window not visible to user

here is the code statement to replace formula with its value:
ExcelAppObject.SendKeys("%EC+{F10}sv{enter}",True);

Thanks and Regards,