In C# is there a way of refreshing query in EXCEL (REFRESH ALL)

Hi All,
Need C# code in SSIS Sript task which should refresh all excel data which extracts from a table using Microsoft query.
Can anyone help at all ?
Thanks 
Sri.Tummala

Hi All,
Found the code to refresh excel data the above code is saving before refrshing so I added application wait for 20 seconds so that it refrshes first than saves it.
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
namespace ST_53932a75e92c44f086535fc017a56e6a.csproj
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region VSTA generated code
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.
To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
To open Help, press F1.
public void Main()
// TODO: Add your code here
ExcelRefresh(@"C:\Documents and Settings\ST84879\Desktop\ROBERT_DATA_SET\TEST.xls");
Dts.TaskResult = (int)ScriptResults.Success;
private void ExcelRefresh(string Filename)
object NullValue = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
excelApp.DisplayAlerts = false;
Microsoft.Office.Interop.Excel.Workbook Workbook = excelApp.Workbooks.Open(
Filename, NullValue, NullValue, NullValue, NullValue,
NullValue, NullValue, NullValue, NullValue, NullValue,
NullValue, NullValue, NullValue, NullValue, NullValue);
Workbook.RefreshAll();
System.Threading.Thread.Sleep(20000);
Workbook.Save();
Workbook.Close(false, Filename, null);
excelApp.Quit();
Workbook = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
Thanks All
Sri.Tummala

Similar Messages

  • Is there a way in Pages to show and print all the added "comments?" (those you add by highlighting text)  I'd like students to be able to view my comments on printed version of their papers.

    Is there a way in Pages to show and print all the added "comments?" (those you add by highlighting text)  I am a teacher, and I would  like students to be able to view my comments on printed versions of their papers. I know word displays the comments off to the side of the document, and those comments can be viewed all at once and printed alongside the document.

    There doesn't appear to be a way to print conmments in either Pages or Numbers in the Mavericks versions.
    Jerry

  • When I save photos or videos from my iPhone 4S to my PC they are all sideways.  Is there a way to prevent this from happening?  All are taking with the phone in portrait mode.

    When I save photos or videos from my iPhone 4S to my PC they are all sideways.  Is there a way to prevent this from happening?  All are taken with the phone in portrait mode.

    Shot videos ONLY in landscape. For photos choose what's you like. Maybe you have to rotate photos on PC. What's your operating system?

  • Is there a way to create a "common desktop" for all RD/TS 2012 users? (Office 2010 icons on the dekstop, for example.)

    Hello!  Just like the title, is there a way to create a "common desktop" for all RD/TS 2012 users?
    I know how to do this using regular W7 workstations and 2008 Servers, but the "Default" folder under the USERS directory is gone and I'm not sure how to get the icons there in Windows 8, let alone Server 2012 Remote Desktop.
    I've installed Office 2010 on the 2012 server, but every end user that logs in has to manually type in "Word," "Excel." "PowerPoint." etc from the metro interface, then right-click each icon to add the shortcut to the desktop.
    Given the... uh.. unfamiliarity of our endusers around the computer, this really isn't the best option.  What I'd like is them to log on and have all the Office icons ready and availible for them.
    Any ideas?
    Matthew J. Fazio

    Hi,
    You can edit the local GPP and create a desktop shortcut for all users.
    Reference:
    Customize the default local user profile in windows Server 2012
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/3f178a0e-128e-4f4f-870a-90c8bbf1afeb/customize-the-default-local-user-profile-in-windows-server-2012?forum=winserver8gen
    Also, you can use CopyProfile to customize the Default User Profile.
    Customize the Default User Profile by Using CopyProfile
    http://technet.microsoft.com/en-us/library/hh825135.aspx
    Best Regards.
    Jeremy Wu
    TechNet Community Support

  • As a graphic designer, I am creating ePubs that will be seen on iPads running, ios5, ios6 and ios7.  Each version displays the page differently.  Is there a way to make the display consistent on all systems?

    As a graphic designer, I am creating ePubs that will be seen on iPads running, ios5, ios6 and ios7.  Each version displays the page differently.  Is there a way to make the display consistent on all systems?

    As a graphic designer, I am creating ePubs that will be seen on iPads running, ios5, ios6 and ios7.  Each version displays the page differently.  Is there a way to make the display consistent on all systems?

  • I was running KeyPassFox with Firefox 8.0.1, but the plugin does not work in the new release (9) . Is there a way to restore my previous version with all of my bookmarks intact? I do not mind if I have to restore the plugins myself.

    I was running KeyPassFox with Firefox 8.0.1, but the plugin does not work in the new release (9) . Is there a way to restore my previous version with all of my bookmarks intact? I do not mind if I have to restore the plugins myself.
    The plugin shows on the list as enabled and functioning, yet the tool does not show on the toolbar. It would appear that I need to restore the previous version of Firefox and wait until a newer release of the plugin is available before upgrading the browser.

    I copied the iTunes file from the external drive and it's in both places.  I thought all I would need is the iTunes program (which I downloaded to new computer) and my iTunes library file.  There must be something else that's missing.  My iTunes library looks the same on the new computer as it does when I open it on the external drive.  If I click on an iTunes library song from my new computer, it will only play if I have the external drive plugged in.
    My back-up drive is a mess.  I have multiple copies of music, video, photo, and document files and I don't know how that happened. ={  Obviously, I don't know how to back up stuff properly and there are back-up files extending over a 6- to 8-year period.  I think all I did was just drag and drop the main folders from the back-up drive to the same main folders on the C: drive.  Also (and I'm kind of fuzzy on this) Windows used to automatically save music files in a folder within my document files (which makes no sense to me).  As my Jewish friends would say, "Oy Vey!" 

  • Is there a way to import data from excel -when one of the columns in excel is hyperlink column?

     Is there a way to import data from excel  - so if a column is hyperlink - the whole data will move to the list (text + link of the hyperlink column)?
    keren tsur

    Hi,
    According to your description, you want to export excel which contains a hyperlink column to SharePoint list.
    Refer to the following steps:
    Open the Excel, insert/create the table. 
    Now click on any cell of table and go to the ‘Design Tools’.
    Click on the Export and then ‘Export table to SharePoint List’.
    You will see a popup where you need to provide the URL of SharePoint site, list name and description.
    Then click on next, On the next screen you will see columns with data types which are going to create in SharePoint list.
    Now click finish and wait until the operation gets finished. You will see that list gets created in SharePoint site with the records.
    Here are two links, you can use as a reference:
    http://sharepointrhapsody.com/2013/03/25/how-to-create-a-connected-excel-file-to-sharepoint-list/
    http://social.technet.microsoft.com/wiki/contents/articles/18705.sharepoint-2013-how-to-export-excel-sheet-to-sharepoint-list.aspx
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • Is there any way to have a COMPLETE list of all samples and loops ( Logic 8

    I'm sure it's been posted previously, but anyway, I'm looking to buy new Apple Loops libraries and I have faced the fact , that many of the sounds and loops produced by third parties manufacturers have been already included in Logic installation discs.
    I have a list of Apple Loops DVD's that have been included with Logic somewhere, the problem is, Apple didn't post ( I believe) the credits of all 3rd party manufacturers that have produced these libraries that are included with Logic or Garage band. Is there any way to have a COMPLETE list of all samples and loops that are included with Apple DAW's so I wouldn't duplicate anything ? I'm pretty much positive that Apple had other companies to sound design and sample all libraries for them, so is there also a way to have a list of those manufacturers? Again, the objection is to start upgrading the sound library without any possible duplication?
    Thanks in advance!

    Chris, I certainly don't mind additional questions and postings.
    I believe there are many issues with Apple Loops and Logic that need to be resolved and people need to be aware of that. Unfortunately, in opposite to the old "german" version of Logic , there's no lifetime tech support, you can't even call and ask the question after 60 days , which isn't right for a professional software of this level, especially considering the fact that many things still remain vague in Logic even for developers and tech support people!( believe me, I've called and asked!)
    Issues like that need to be resolved over the phone with the company, period!
    One thing I also learned over the years as a Mac OSX user, if something doesn't work, don't mess with it. Delete your drive and re-install everything. This is very frustrating , I know, but unfortunately this is the only way to deal with OSX issues, if you got a problem with your system, don't try to fix it. It's never gonna be the same again. I know , it's off the topic a little bit, but if your content is missing from the system files, before installing your new Logic, back up your important files, wipe up your drive and clean install Mac OSX , run updates and then install the Logic. Most likely , everything will be in it's place, at least 90% or more. I gave up trying to make two system in my house to be compatible 100% , but it's OK if they're 90% or more identical. I spent enormous amount of time trying to find out what's missing and where, I visited most of the forums and there's no clean answer.
    Message was edited by: Moderator

  • I have been using the apple IPad camera connection kit and my photos can be viewed in the events... But the all imported folder is no longer there and the last import folder is empty. Is there any way to resolve this ang get my all imported folder back?

    I have been using the apple IPad camera connection kit and my photos can be viewed in the events... But the all imported folder is no longer there and the last import folder is empty. Is there any way to resolve this and get my all imported folder back? as well as get my last import functioning normally?

    Please please help me, if you know how.

  • Is there no way to update the "Default Lables" on all slides once I've changed it under the Preferences?

    Is there no way to update the "Default Lables" on all slides once I've changed it under the Preferences?
    I really don't want to recreate the slides from scratch again.

    What about File, Export, Text Captions...? You'll have a Word document with two columns. Translate the second column (much easier in Word) and import again. That is the normal work flow for translation. Same is possible with XML instead of Word.

  • I have deleted all my bookmarks from firefox sync by error on reintalling operating system. Is there any way to recover it? I have all bookmarks saved on "Firefox Home" on my iPod. Can I extract bookmarks from "Firefox Home" to my computer? Thanks

    I have deleted all my bookmarks from firefox sync by error on reintalling operating system. Is there any way to recover it? I have all bookmarks saved on "Firefox Home" on my iPod. Can I extract bookmarks from "Firefox Home" to my computer? Thanks

    Restore your backup.

  • Is there a way to delete everything on the cloud all at once and start over?

    We tried to store a lot of photos to the cloud in one copy. The files have been syncing for over 24 hours. We tried to stop the sync and just throw everything away, and they still show up in the archive. Is there a way to delete everything on the cloud all at once and start over?

    Dulls for information on how to permanently delete your files please see Creative Cloud Help | Manage and Sync files.

  • Is there a way to have one flash player play all moives on a web page ?

    Hi,
      Is there a way to have one flash player play all movies on a web page ?   For example, you have a list of FLV movies on a page and you click on any them and it will play on the same player on the web page. Or does each movie needs it's own ?
    Thanks in advance..
    Peter

    Yes, for the design I made, the movies are loaded from the server.  Here is the code for the design.  It is done using AS2, and the stage includes two buttons (s1, s2) for playing the individual videos, one button to play them both (playall), one after the other, and the video object (video1_video) that was added via small menu you find at the top of the library panel's frame.
    I cannot say this would work directly for your implementation, but it gives you some things you can look into so that you can figure out how.
    function(){return A.apply(null,[this].concat($A(arguments)))}
    // ignore whatever code is above this... the forum added it, not me  
    stop();
    ncount = -1;
    var connection_nc:NetConnection = new NetConnection();
    connection_nc.connect(null);
    var stream_ns:NetStream = new NetStream(connection_nc);
    stream_ns.setBufferTime(3);
    stream_ns.onStatus = function(infoObject:Object) {
            for (var prop in infoObject) {
                   if(infoObject[prop] == "NetStream.Play.Stop" && ncount == 0){
                       video1_video.attachVideo(stream_ns);
                       stream_ns.play("20051210-w50s.flv");
                       ncount += 1;
    playall.onRelease = function(){
          ncount = 0;
          video1_video.attachVideo(stream_ns);
          stream_ns.play("barsandtone.flv");
    s1.onRelease = function(){
          video1_video.attachVideo(stream_ns);
          stream_ns.play("barsandtone.flv");
    s2.onRelease = function(){
          ncount = -1;
          video1_video.attachVideo(stream_ns);
          stream_ns.play("20051210-w50s.flv");
    I don't deal with video very often, so I have not created an AS3 version of this.

  • Is there a way to assign a network printer to all users?

    We are in the process of placing new computers in a lab of imacs.  Is there a way to add the new printer to all accounts on the macs or will i need to add the printer for every account listed?

    If you are using the server version of OS X this should be an extremely simple task. If you are not the printers will need to be installed on each iMac individually.

  • Is there a way to publish a collection set including all subfolders as a smart publishing service 1)

    is there a way to publish a collection set including all subfolders as a smart publishing service 1) to the hard drive and 2) to flickr while also automatically creating all subfolders? i manage to do this only with collections, but not with the partent collection set.

    It's not AIR that's lacking the key in the plist, it must be Flash Pro, although it's just running adt itself. I use AIR 3.4 and I compile via adt command line (because Flash Builder 4.6 still has not been updated to handle warnings from ANEs during compile, grr). I have CFBundleDisplayName in my plist file. Have you tried compiling on the command line?
    Here's an Adobe page with a bunch of examples compiling with ADT on the command line:
    http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca935b-8000.html
    Being unaware of what in-house distribution system that actually is, I have noted that some people had previous issues submitting apps Flash compiles. Their solution was to rename the AppName.ipa to AppName.zip, extract the Payload folder, copy the AppName.app inside there out, then rename that AppName.app to AppName.ipa. Then it was accepted. Not sure if that old issue still exists.

Maybe you are looking for

  • Create text editable PDF for client to edit in Adobe Reader

    I would like to create a PDF from either Illustrator or InDesign so that my client can edit just the text in the document using Adobe Reader as necessary (for flyers and business cards etc). I want to set the file up in Illustrator or InDesign so all

  • How to access another resource in Groupwise

    Could anyone tell me or direct me to a sample of some code, that shows how to access another resource in Groupwise with VB. The main goal is to send a appointmentsfrom another resource by accessing this resource that you have authority from own maila

  • XLR run-time error when upgrading from 2007A PL 39 to PL 42

    My client recently upgraded from 2007A PL 39 to Pl 42, In PL 39, everything, including XLR, was running smoothly. Mow when client tried to open SBO, he gets this message: XL Reporter Run-time error u2018430u2019: Class does not support Automation or

  • Hanging BPEL process after DB re-start

    10.1.2, Linux We have a BPEL process that uses an AQ adapter to receive messages from an Oracle 9i DB. This works great most of the time. We have noticed however that if the 9i DB is re-started for any reason, the BPEL AQ Adapter is unable to re-esta

  • HT3060 right shift key not working

    hello. Recently, my right hand shift key has quit working on my bluetooth wireless keyboard. Any suggestions?  Software is up to date.