1

I have UI tests. When the UI tests finish, they open the result files in an Excel document (Excel 2007 is installed on the test environment) - but the problem is that the excel document is not saved anywhere on the computer. They exist only when the AutoRecover feature saves the temporary files as a .xar file, so this is useless to us.

We use a C# .NET program to launch the UI tests (and do a bunch of other things), so I'm looking to see if it's possible to save this OPENED excel document programmatically.

Is that possible?

Thanks

1 Answer 1

1

This may help you How to: Save Workbooks

Example

This example creates a new workbook, prompts the user for a file name, and then saves the workbook.

Set NewBook = Workbooks.Add
Do
    fName = Application.GetSaveAsFilename
Loop Until fName <> False
NewBook.SaveAs Filename:=fName
Sign up to request clarification or add additional context in comments.

6 Comments

Yep, this will work as long as he has a handle to the running excel application (which I imagine he would).
Hi, thanks for the reply. Can you re-write this in C# .NET? In the web page you linked to, they make use of the 'this' keyword, but how is this supposed to work? I want the code to save an excel document to be part of a C# .NET automation program... I tried putting together some code and used the Microsoft.Office.Interop.Excel DLL reference but I wasn't able to figure out how to use it to save documents using the MDSN documentation. Would you be able to provide more information? Thanks
@user606602: This is a very simple example to read, save an excel file c-sharpcorner.com/UploadFile/jayendra/5443
Hi Thomas thanks, but the code in the article does not really help, and I don't think it's simple. For example, take a look at the code for saving: 'object objOpt = Missing.Value; objBook.SaveAs(newFilePath, objOpt, objOpt, objOpt, objOpt, objOpt, XlSaveAsAccessMode.xlNoChange, objOpt, objOpt, objOpt, objOpt, objOpt);' What is this Missing class for example? This doesn't make sense to me. Have you ever tried this yourself?
@user606602: It is in System.Reflection namespace and it just tell that object is missing or not available.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.