Cfobject and Excel

Really hoping someone can help me on this one....... I am
trying to export query data to Excel using cfobject, creating the
spreadsheet is fine and even formatting the cell borders,
backgrounds etc but when I try and set the value for a cell range I
keep getting the following error
AutomationException: 0x800a03ec -
Please can someone help on this as I have spent the last day
or so browsing the web and so many of the examples just do not seem
to work.
Here is my code below
Regards,
Leigh
<cfquery name="monkey" datasource="training">
SELECT * FROM orders
</cfquery>
<CFTRY>
<!--- If it exists, connect to it --->
<CFOBJECT
ACTION="CONNECT"
CLASS="Excel.Application"
NAME="objExcel"
TYPE="COM">
<CFCATCH>
<!--- The object doesn't exist, so create it --->
<CFOBJECT
ACTION="CREATE"
CLASS="Excel.Application"
NAME="objExcel"
TYPE="COM">
</CFCATCH>
</CFTRY>
<cfscript>
// Open Excel in the background
objExcel.Visible = true;
// Disable client alerts such as: 'Save this workbook?'
objExcel.DisplayAlerts = false;
// Define the workbooks object
objWorkBook = objExcel.Workbooks;
// Add a new workbook
objOpenedBook = objWorkBook.Add();
// Get the WorkSheets' collection
objWorkSheets = objExcel.WorkSheets;
// Add a new worksheet (this will contain our data)
objWorkSheet = objWorkSheets;
// Add a new worksheet (this will contain our data)
objWorkSheet = objWorkSheets.Add();
//Create object Interior for solid field some color
objRange = objExcel.Range("A1:K1");
objI = objRange.Interior;
objI.ColorIndex = 15;
objRange = objExcel.Range("A1:K1");
objIn_V = objRange.Interior;
objIn_V.ColorIndex = 12;
objV = objRange.Font;
objV.Size = 08;
objRange.HorizontalAlignment = 3;
objRange.VerticalAlignment = 1;
objLine = objRange.Borders;
objLine.LineStyle = 1;
objRange.WrapText = True;
objRange.ShrinkToFit = True;
objRange = objExcel.Range("A3:A3");
objRange.value = 15;
objWorkSheet.SaveAs("c:\templates\testfile5.xls",Val(1));
// Close the document
objWorkBook.Close();
// Quit Excel
objExcel.Quit();
// Release the object
objExcel = "Nothing";
</cfscript>

First make sure you have proper permissions to the Excel
file. That is the most common cause for the error. You need to have
r/w permissions.

Similar Messages

  • Use VBA and Excel to open Dreamweaver HTML (CS5), find and replace text, save and close

    I wish to use VBA and Excel to programmatically open numbered Dreamweaver HTML (CS5) and find and replace text in the code view of these files, save and close them.
    I have  5000 associations between Find: x0001 and Replace: y0001 in an Excel sheet.
    I have the VBA written but do not know how to open, close and save the code view of the ####.html files. Please ... and thank you...
    [email protected]

    This is actually the code view of file ####.html that I wish to find and replace programmatically where #### is a four digit number cataloguing each painting.... In 1995 I thought this was clever... maybe not so clever now :>)) Thank you for whatever you can do Rob!
    !####.jpg!
    h2. "Name####"
    Oils on acrylic foundation commercial canvas - . xx X xx (inches) Started
    Back of the Painting In Progress </p> </body> </html>
    Warmest regards,
    Phil the Forecaster, http://philtheforecaster.blogspot.ca/ and http://phils-market.blogspot.ca/

  • How do I make Word and Excel Documents readable to PC users that cannot open them

    How do I make Word and Excel Documents readable to PC users that cannot open them

    Be sure to save them in the Office 2007 format as .doc or .xls files.

  • REPORT GENERATION TOOLKIT AND EXCEL

    i have a problem with report generation toolkit and excel
    the problem is:
    i must read & write from a excel worksheet when this is open but when i using the report generation the worksheet is open another time
    have some solution for this problem?
    sorry for my english

    You need to close Exel when before your VI is running. Excel can not have two instances running at the same time.
    Joe

  • Adobe photoshop,word, and excel  won't open on my 2010 air mac

    adobe photoshop,word, and excel  won't open on my 2010 air mac. Message says I have lost my power pc connection. this happened while in Mexico

    Adobe Photoshop CS2, MS Word 2004 and other PPC apps running in Snow Leopard Server installed into Parallels  for use in Lion or Mt. Lion:
                                  [click on image to enlarge]
    More information here:
    http://forums.macrumors.com/showthread.php?t=1365439

  • My microsoft word and excel programs won't work and files won't open.

    After an automatic HP update, my Microsoft Word and Excel programs won't work and my files won't open.  What caused this and what can I do to fix the problem without losing my files?  I have files that are part of my work and I HAVE to have them ASAP.  Please help.
    Thanks in advance.

    Hi
    Please find the steps to resolve your issue.
    Open Installed Updates by clicking the Start button , clicking Control Panel, clicking Programs, and then, under Programs and Features, clicking View installed updates.
    Click the update that you want to remove, and then click Uninstall.  If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
    Or Try this step
    If this does not resolve your issue then you can try a System restore to the date where unit was working fine steps provided below for you.
    Start in search box type System Restore then click on it then select the Date where unit was working fine.
    Let us know how it goes!
    "I work for HP."
    ****Click the (purple thumbs up icon in the lower right corner of a post) to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    Regards
    Manjunath

  • BO XI 3.1 SP3 and Excel 2010

    Hi There
    My BO is BO XI 3.1 SP3, and excel is 2010, my webi report has over 65523 rows, but I found in the excel, it will split into two tabs, it does not use excel 2010 feature
    does any one know the reason?
    thanks

    Excel 2010 is not suportive by BO XI 3.. It is possible in BO XI 4.0. You can try What Gowtam Allu said, but I am not sure if it works.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/4079f8f6-2b49-2d10-d790-bc596012dc25?quicklink=index&overridelayout=true

  • How do I get windows and excel on my iPad

    I want to use my iPad 2 for my business but need word and excel....how do I do this?

    There is no Word or Excel for iPad or any other iOS device, but you can use other Apps to edit these files.
    http://www.zdnet.com/blog/mobile-gadgeteer/ipad-office-app-showdown-four-apps-to -help-you-get-work-done/3445

  • The dock in Maverick is doing strange things to word and excel files

    For years (and Mac operating systems), I have kept Microsoft word and excel documents on my doc. I use these documents frequently...click on the file icon in the dock, it opens, I edit and save. Click on the icon again and the saved document opens. so simple.
    Since upgrading, I click on the icon, the file opens with a number following the file name (version number I assume) but before docx or xlsx. I edit and save, but get a "save as" box. Now I have to edit the file's name, find the original and replace the original with the new version. Not so simple.
    Since I open and close my daily billing log many times a day, this has slowed me down (and irritated me).
    I have had no other problems with my Maverick installation and these files are in Word and Excel 2008. This does not happen to powerpoint or any other file I tried so far.
    Any suggestions on how to solve this?

    Your Mac will generate a new .plist file automatically after restart.
    Deleting the .plist file shouldn't delete any app icons from the dock.
    Check the startup disk just in case.
    Launch Disk Utility located in HD > Applications > Utilities
    Select the startup disk on the left then select the First Aid tab.
    Click:  Verify Disk  (not Verify Disk Permissions)
    If DU reports errors, restart your Mac while holding down the Command + R keys.
    From there you can access the built-in utilities to repair the disk using OS X Recovery

  • VB6 and Excel loading then unloading immediately

    First off I posted this here
    http://social.msdn.microsoft.com/Forums/office/en-US/4c07879b-e033-4e8f-8266-95f9f606923a/vb6-and-excel-loading-then-unloading-immediately?forum=exceldev However I think this is the right forum for this.
    We have an old VB6 application that uses data from and to Excel 97-2003 XLS and
    Access MDB. This application is slated to be updated to VS2012 and VB.NET. In
    the mean time I have a glitch that I cannot seem to find the issue. When we
    load the VB6 app it opens Excel 2010 in the background for getting and setting
    data. We are set to roll out Office 2010 on everyone’s system and I am still
    unable to find why it works fine on two systems and not on others. With Office
    2007 everything seems to work just fine.
    What happens is when I look at the processes in Task Manager on my Windows 7
    Enterprise edition with Office Professional Plus 2010 system while loading
    the VB6 app I see?
    EXCEL.EXE *32 | "My user name" | 00 CPU | 10,132k | Microsoft Excel
    This is normal and stays in process the entire time I run it on my system. I also have
    this working on another end users system. However the issue and the fix I used
    on our two systems does not seem to work on other systems. I launch the VB6 app
    and it comes up.
    EXCEL.EXE *32 | "My user name" | 00 CPU | 10,132k | Microsoft Excel
    This loads in the processes and then immediately unloads without any errors. Then when I
    execute something that needs to use Excel I get.
    Run-Time error ‘91’:
    Object variable or With block variable not set.
    This only happens if Excel unloads immediately otherwise the program works great. There
    are no events in any of the event logs and our other IT guy said it is loading
    and unloading normally with out crashing.
    I have applied this to the systems http://support.microsoft.com/kb/926430/en-us . In
    all of my searching this looked like the best answer. However only two systems
    are working with Office Professional Plus 2010.
    Here are the references and components.
    References:
    Visual Basic For Applications
    Visual Basic runtime objects and procedures
    Visual Basic objects and procedures
    OLE Automation
    Microsoft DAO 3.6 Object Library
    Microsoft Excel 5.0 Object Library
    Components:
    Controls
    Desaware Animated Button Control
    Microsoft Common Dialog Control 6.0 (SP6)
    Microsoft Data Bound Grid Control 5.0 (SP6)
    Designers
    Dat Environment
    Data Report
    DHTML Page
    WebClass
    Code:
    Public xlApp As Excel.Application
    Public WBSetup As Excel.Workbook
    Public objWbCALC As Excel.Workbook
    Public objShtLEVELS As Excel.Worksheet
    Sub Main()
    ' There is more code here that is not specific to Excel issue
    Set xlApp = Excel.Application
    ' Get the workbook.
    Set objWbCALC = xlApp.Workbooks.Open("c:\temp\Calc.xls")
    Set WBSetup = xlApp.Workbooks.Open("c:\temp\Setup.xls")
    ' Get worksheet
    Set objShtLEVELS = objWbCALC.Worksheets("Levels")
    ' There is more code here that is not specific to Excel issue
    End Sub
    This is working on one system that had Office 2007 and was upgraded to Office 2010. Working on my system with Office 2010. The EXE file is ran from the server you can install it or add the OCX files to local system and register them with regsvr32. No
    new components have been added or changed to the actual VB6 application. It seems to work on two systems and not on other systems.
    However our test system have Office 2010 loaded on it and never had office 2007 on it. Maybe there is a residual left over file on it.
    Any ideas?
    www.ipdg3.com

    Hello,
    Thank you for your post.
    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    I would like to know whether you can get the same issue when you create/load a Visual Basic application rather than VB6 in VS2012. If the issue only occurs when you load VB6 app, as Andrew said, there are other better forums for
    VB6 app provided in this thread:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b/where-to-post-your-vb-6-questions?forum=vbgeneral
    For example:
    VB Forums
    VB City
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How do i get word and excel on my mac

    Hi,
    I have recently bought a Mac book pro. Till now have been using a acer laptop.
    can any one help with the following
    I want to transfer all my data( mostly word, excel and photos) to my Mac
    what software do i use to in Mac to be able to use the word and excel.
    Please help. Iam not computer savy so going nuts now.

    Welcome to the Apple Forum, sujithna!
    sujithna wrote:
    ...a Mac book pro. Till now have been using a acer laptop.
    can any one help with the following
    I want to transfer all my data( mostly word, excel and photos) to my Mac
    Take a look at the options to Transfer data from a PC to a Mac. Consider the first option with Migration Assistant.
    HTH

  • I am unable to open the microsoft word and excel and pdf files after upgratding to 4.3.3 os version

    I am unable to open the microsoft word and excel and pdf files after upgratding to 4.3.3 os version. I was able to access them in 4.3.1 .
    Can anybody tell when is this getting resolved.

    http://support.mozilla.com/en-US/kb/Recovering+important+data+from+an+old+profile
    Your old Profile is located here in Vista & Win7: <br />
    ''drive'':\Users\''Windows login user name''\AppData\Roaming\Mozilla\Firefox\Profiles\''profile_name''

  • I am thinking of changing to a IMaC for my computer and Want to know if I will be able to upload documents from my old computer and all my photos. Everything is in Microsoft Word and excel. I have a iphone and ipad so that is why i am thinking of changing

    If I change to a IMAC will I be able to upload all my photos and word and excel documents? Also does it have USB ports like I have already used?
    Is there a DVD player on IMACS? It is scary making the move until I am sure I can use everything I already have.  I also have NEAT for all my recepits also.

    When the new Mac first starts up, you get the opportunity to migrate your files from another computer, including a PC. This link tells you how to do it from Windows.
    As for the iMac's features, you can look through this website to get all the details.
    It is possible to install Windows on a Mac and run your Windows applications within it. It's also possible to use programs that are for the Mac which can work with most MS Office files. One good example is LibreOffice.
    Welcome to the Mac.

  • HT3258 Will Word and Excel still work if I upgrade to Mount, Lion

    If I upgrade to M. Lion, will the Word and Excel programs I have on my Mac still work?
    Thanx - M

    It depends on which version you have. If they are very old PowerPC only programs - over six years old or so - they will not run.
    A better solution is to try a number of better, free alternatives. Consider
    LibreOffice (donation-supported)
    NeoOffice (free)
    OpenOffice (free)
    I use Apple's Pages ($19.99) as well as OpenOffice and have been completely Microsoft - free for over a year now. Life is better without Microsoft.

  • Reuse_alv_grid and excel

    i read many threads about alv and excel specially about the trouble with excel with the line missaligned but didn't see a solution.
    i have the same trouble i have an alv_grd with 30 col. but when i export to excel only the first 27 are aligned the last 3 are missaligned in un another row.
    so i ask if there are some rules to export correctely in excel.
    I must say that i see the same missaligment with the print of the alv.
    Is it possible to choose the width of the col therefore is it possible to have rows with different higth?
    thanx.

    Hi,
    I think there is some limit on characters, not sure whats the limit. Might be somewhere aroung 1032 or something.
    You can not break columns into number of rows. What you can just try is just reduce the width of the columns a bit and check if the 30 columns getting transferred correctly or not.
    Regards,
    Atish

Maybe you are looking for

  • Other servers

    Hello! One question: if I import a site (that I've in diffferent server from .Mac) in iWeb, I modify it, than can I publish it on that server (always different from .Mac) or can I publish only in .Mac? Thanks! Emiliano

  • Stop Direct Cost Center Postings

    Hi, Is there any method in CO to block direct cost center postings in Plant/Business Area Wise? All the posting should be made through Internal Orders and no direct Cost Center postings are allowed. Is there any possibility to do this in the system.

  • Preserving play data with fresh install

    Due to a catastrophic error and probably too much trying to repair it without assistance, I'm forced with the prospect of uninstalling iTunes (9.0) and reinstalling 9.2. However, I've accumulated 7 years of playlists and play data that I'm unwilling

  • Filtering an analog signal

    i am taking voltage readings as analog signals and was wondering do i need to filter the signals that come from the daq assistant. i tried smoothing the signals but this did not match the values that i should be getting is there any other filter sign

  • Hhctrl.ocx

    I'm getting an annoying error message when I open iTunes... it goes like this:- "iTunes.exe - Bad Image C:\Windows\System32\hhctrl.ocx is either not designed to run on Windows or it contains an error." There follow messages about contacting the vendo