Office Automation :: Runtime Error "Activesheet.unprotect Stating Unprotect Method Of Worksheet Failed" 1004

Dec 7, 2011

I am working on a large spreadsheet with Macros. It worked fine when I only had one spreadsheet that the code was pulling from. When I added an array, I get the an error on the Activesheet.unprotect stating 'unprotect method of worksheet failed'.


Worksheet.Unprotect - Office Interop - Difference Between 2003 And 2007?

Mar 11, 2010

I have a .NET winforms app that automates Excel and checks for a worksheet password. The requirements are to be able to detect

1) that the protection is turned off

2) that the password is removed (protected but there is no password)

3) that the password matches the correct password from a database

To meet the second requirement the program calls the Worksheet.Unprotect command with a null string, capturing the error. If error as expected, the 3rd check is made. If no error, then the Unprotect worked without a password ==> password was removed.

The code sample below has these checks.The application can do this fine with Office 2003. I have since had my dev machine updated to Office 2007 and it no longer works as it did. When I call the Worksheet.Unprotect, Excel prompts for the password!

I need to know how this should be accomplished in the new version of Excel or if there is a way to reference the old PIA. No matter what if I set a reference to Excel 11 it is replaced with the PIA for 12 in the GAC.

'return true if unprotect of worksheet does not generate an error
'all other errors will bubble up
'return false if specific error is "Password is invalid..."


View 1 Replies View Related

VBA Error 1004 - Select Method Of Range Class Failed?

Mar 25, 2010

VBA error 1004 - select method of range class failed

View 2 Replies View Related

Office Automation :: Excel Worksheet.PageSetup.ChartSize Property Error

Jul 23, 2009

I've automated quite a bit with excel and every so often one of these really annoying glitches pops up.I'm using Office 2003, all with latest service packs and everything, and basically I usually end up creating a lot of applications which automate excel, processing database information and exporting it etc, etc, etc.

I currently have finalized this most recent export process, which exports a moderately sized table into excel for the user to work with, but I wanted to adjust the printing area appropriately.SO, I set the PrintArea to the A1:K47 string, I set the FittoPagesTall/Wide to 1 and the Orientation to Landscape, and all of this is perfectly functional from my 2008 .Net 3.5 application. But in the open application window of the file i'm automatically creating, the page divider lines still show 4 pages of data. Now, I said to myself, i know that in the Page Setup Dialog I can set "Fit to Page" and it automatically adjusts the zoom factor (scaling) to fit the print area onto 1x1 pages.

The only property in the WorkSheet.PageSetup that appears to do this is the ChartSize property, but when I step over that line in the Application I'm debugging, I get the Exception:"Unable to set the ChartSize property of the PageSetup class"Now the only thing i've seen online about this error from Microsoft says it could occur when a printer isn't installed. That is not the case here.

I further looked up in the property and it said something about only being applied to "Chart Sheets" but when I try to use the workbook.worksheets.add() method witht the Type set to xlChart I get a com object disconnected from RCW error.NOw, I can manually go into the Page Setup Properties for the Excel Worksheet, and set the "FIt to Page" there, so How can I forcibly automate this exact same process without having to open the Excel APplicaiton.

View 3 Replies View Related

Protection Of Exe - After 60 Of Days Of Installation - Ask Password To Unprotect The Exe

Jul 9, 2009

I have already a projet and now I wanted to protect this exe as after 60 of days of installation it should ask password to unprtect the exe.

View 1 Replies View Related

Office Automation :: Catching Excel Runtime Error From A WinForm?

Dec 30, 2009

[URL] using this method results in a modal dialogue box which the user must manually close by pressing end or debug or the VBA (and consequently the VB) code will hang.I am unsure how to get the message box to close.

View 11 Replies View Related

Office Automation :: How To Catch An Excel Runtime Error From A WinForm

May 15, 2008

I am writing a WinForm app on Visual Studio .Net 2005 which will be a rudimentary "unit tester" for various MS Excel 2003 applications...basically, it will ensure the integrity of the VBA code which fires off in the event lifecycle of the workbook.As a test for a "unit test failure," I created a simple workbook which generates a runtime error at the Workbook_Open event in the VBA code (an intentionally placed out-of-index call to an array). I have no problem opening workbooks via the .Net WinForm using the Excel Object library. My problem is that the run-time error is not captured by the WinForm app -- instead, it throws the runtime error directly on the Excel thread which the WinForm app starts.Is there a way for the WinForm app leveraging office interop to catch that excel runtime exception?

I've tried encasing the call in a Try-Catch block using a general Exception a COMException (via the System.Runtime.InteropServices library) catch...I've also tried instantiating the workbook directly using CreateObject(sPath) and instantiating an Excel Application, then using that to open the workbook...all with the same results...instead of the .Net app catching the exception, the runtime error bubbles up directly to the Excel application.Is there any way, either on .Net or the VBA code, for the WinForm app to catch and handle an Excel run-time error?

View 13 Replies View Related

Office Automation :: Copy Worksheet To Another While Preserving The Original Format

Dec 8, 2009

I am using Visual Studio Professional 2008. I am writing a program in Visual Basic 2008 that copies the Used Range from one worksheet to another worksheet, I am able to achieve this by the following code segment:


View 5 Replies View Related

Office Automation :: Populate Spreadsheet 11.0 Control With Existing Worksheet

Sep 25, 2010

I have a spreadsheet control on a windows form that I would like to populate with data from an existing worksheet (myworkbook.xls, sheet1).

View 4 Replies View Related

Office Automation :: Use Common Worksheet Functions Found In Excel 2003?

May 3, 2010

I'm trying to use common Worksheet functions found in Excel 2003 (average, standard deviation, etc) from within VS 2008. See thinned down sample code below:

Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


When ran it returns "New cannot be used on an interface". Removing "New" returns "'WorksheetFunction' is a type in 'Excel' and cannot be used as an expression."

I've added a reference to the Microsoft.Office.Interop.Excel library v11.0.0.0, which I'm using in other places in the code with no complaints.

View 3 Replies View Related

VB Runtime Error 1004 - Excel File - Save ?

May 27, 2008

Here are some important facts:

This code works (no Error 1004 on numerous laptops and desktops) A couple of months ago it began to fail (Error 1004 reared it's ugly head) on a couple of machines. The users claim that nothing changed - I can neither confirm nor deny accuracy of these claims. All users, except one, are running Windows XP and Office 2003. The problem also surfaced on a new machine running Windows XP and Office 2007. I could not force the error on my development/test machine - Windows XP with Offic 2003. It fails every time on another machine I have running Vista with Office 2007

The following is the code that causes me the problem.  I know the error is raised on the WB.Save statement. I added the error trap to eliminate the problem of the Excel file being unaccessable without a reboot, due to the fact that Windows thought Excel still had it open.

Public Sub ExportCostAnalysis(ByVal RunMode As String)

On Error GoTo ErrorHandler

  As dao.Recordset


View 8 Replies View Related

Runtime Error 1004 : Unable To Get The Correl Property Of The Worksheetfunction Class

Apr 9, 2012

my error code is run-time error 1004 unable to get the correl property of the worksheetfunction class. I read the data from xlsx-files to one dimensional arrays in my vb - program. the essencial code parts are

Option Explicit
Option Base 1
Dim winvyf() As Double, winvx() As Double


View 1 Replies View Related

Excel 2007 Macro - Runtime Error 1004 After Saving And Re-opening A File

Oct 25, 2009

I have an Excel file with utilizes macros to allow a user to enter names of people and then double click on cells to enter ratings via radio buttons. When I open a blank file and enable the macros, I can add users, rate their skills using the radio buttons, etc. with no issue. I then SaveAs the file and continue working on it. once I Save and CLOSE the file, then go to re-open it, the trouble begins. Keep in mind, there is no alteration to the macros directly. Just entering data and using the form as intended. Here's what happens.

I reopen the file.I enter in the name of a person on one line.  I go to the first box - double click on it.It is supposed to pop up a dialog box which allows me to choose a rating via radio button (as I had been doing before I closed the file).  Instead, in that first column of ratings, it instead gives me the following error:

Runtime error '1004'Unable to set the LineStyle property of the Border class

When I hit "debug" this is the code it points to:

If ActiveCell.Column = leftb Then Range(Cells(ActiveCell.Row, leftb), Cells(ActiveCell.Row, rightb + 1)).Borders(xlEdgeTop).LineStyle = xlContinuous I have no idea why this would not work when I re-open the file!

note that when I go to click on the subsequent cells (there are 8 cells in which you provide ratings, moving across the columns with each cell) - the 2nd through 8th cells function fine. The dialog box pops up, the rating can be selected.  it's just the FIRST cell that gives the issue What would possibly be the cause of this? We need users of this form to be able to save, close, and re-open it if needed.

View 1 Replies View Related

Office Automation :: 1 Error After Option Strict On?

Feb 15, 2012

i turned Option Strict Onand i get an error on all the ".Cells" lines saying option strict on disallows late binding.

a = 1
b = 3


View 1 Replies View Related

Office Automation :: Error Opening Excel In A Dll?

Apr 25, 2012

We have created a dll to convert an excel spreadsheet to a csv file. At the moment we open the xls file, an eror occured (file doesn't exist / is used by an other user)

Used code:
Dim excel As New Microsoft.Office.Interop.Excel.Application
Dim wb = excel.Workbooks.Open("d:my.xls") '<<<<<<<<<<< not possible to open
wb.SaveAs("d:my.csv", Microsoft.Office.Interop.Excel.XlFileFormat.xlTextMSDOS)

View 1 Replies View Related

Office Automation :: Excel Automation - Cannot Use Office PIAs

Feb 14, 2009

It appears that when one creates an instance of Excel, using CreateObject, (Late binding), the suggested Excel closing function (with GC.collect etc) does not work. I have tried several suggestions, and the only one that works is process.kill method. Do you see any problem in using this? BTW: the reason we are using late binding is that we cannot use Office PIAs....not sure which version of Office would be installed on the client site. We work with O2003, but the client might still be at 2000 or 2002.

View 7 Replies View Related

Office Automation :: VBA Using DLL Error - Methode Get_ContentTypeProperties Has No Implementation

Mar 26, 2012

EXCEL-VBA opens a COM-DLL that -at one place- refers to a class from a another NET-DLL. When the COM-DLL tries to initialize an object from a class (in the NET-DLL) i get an error that the methode get_ContentTypeProperties has no implementation. (--> attached file contains message).

I never created the method get_ContentTypeProperties, nor is it part of the interface i'm using. When accessing the COM-DLL via another DLL, to workaround EXCEL-VBA, it works properly.

View 3 Replies View Related

Office Automation :: Error Creating Word Documents On Server

Jan 24, 2011

I am not an expert programmer and am just getting familiar with .NET office automation. I have two questions:

1. For me to create word documents from my code on a server, does word have to be installed on the server? My test server does not have word installed. Is there a way to have the code open word on the user's machine in this case?

2. I am trying out some code for creating word documents. It works fine on my machine. However, when I try to run it on server it gives me an error.. "Cannot create ActiveX component." Is this a permissions issue or related to the fact that the server does not have word installed?

View 1 Replies View Related

Runtime Error '-2147024894 (80070002)': Automation Error

Jan 4, 2012

i have created a com class library with i have registered the dll with regasm. Then i imported and used it to a vb6 project. I have noticed that if i unregister the library and register it again then i get the following error:

Runtime error '-2147024894 (80070002)': Automation error.

In order to make the library usable again, i have to rebuilt the library with different ClassId, InterfaceId, EventsId at the classes and then register the new dll.

PS: it also does the same thing if i overwrite the registered file with the same file or if i rename its folder and then rename it back to its previous name. Rebuid and re-registered is needed.

View 10 Replies View Related

Office Automation - Excel Chart - Error: Unhandled Exception Of Type

Feb 6, 2009

What I'm trying to do is create an excel chart in a spreadsheet that I've just created using VB.Net code. I get the spreadsheet and chart created fine but then I get this error. An unhandled exception of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll. Additional information: Public member 'xlColumnClustered' on type 'Integer' not found. [Code]

View 1 Replies View Related

Runtime Error - Class Does Not Support Automation

Aug 11, 2011

I created a simple VB 6 executable that runs fine on my computer (Windows 7), but when I deploy it to another Windows 7 PC or a Windows 2003 server, I get the error:
"Runtime Error 430: Class does not support Automation or does not support expected interface".

The code
Private Sub cmdStart_Click()
Dim rstLogin As ADODB.Recordset
MsgBox ("Before first recordset")
Set rstLogin = New ADODB.Recordset
MsgBox ("After first recordset")
End Sub

The line that generates the error is " Set rstLogin = New ADODB.Recordset". I had a coworker compile it from his Windows 7 pc and run it on other machiens and it works fine. So I believe it's an issue with my pc config.

View 4 Replies View Related

Error - Method 'HasTitle' Of Object '_Chart' Failed

Mar 15, 2007

With ActiveChart        .HasTitle = True        .ChartTitle.Characters.Text = "DIRECTIONS"        .Axes(xlCategory, xlPrimary).HasTitle = True        .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "DIR"        .Axes(xlValue, xlPrimary).HasTitle = True        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "DISTANCE"    End With

View 2 Replies View Related

Method Of Object Failed Error While Opening Any Vbp File In VB 6.0?

Nov 10, 2010

Whenever I open any VBP file in Visual Basic 6.0, I get Method '~' of object  '~' failed error. After that project compiles without any error i.e I can create either EXE or DLL without any error. Originally, all files are Visual Basic 5.0 vbp files and we are converting Visual Basic 5.0 to Visual Basic 6.0. We will be converting to .Net after converting to VB6. Application uses microsoft access as data storage.I am running Windows XP on my machine. I have got .Net 3.5, Jet 3.5 Sp3, Microsoft Office 2003 installed on my machine. 

View 8 Replies View Related

Office Automation :: Automatic Deployment Of Excel Automation Addin?

Jan 25, 2011

I have written an automation addin in Excel with C# (addin.dll). To use the addin, I need to 1. register it using "regasm /codebase c:...addin.dll"2. select in ExcelOptionsAddInsExcel AddinsAutomation the respective addin from the list

I would like to automatize 1) and 2), so that the user just needs to run an exe-file in order to use the addin. 1) should be no problem, but how can one automatize 2)?

View 12 Replies View Related

Office Automation :: Excel 2003 Automation With VB 2005 Express?

Apr 20, 2010

Ok basically what I need to do is the following:Read FirstExcelDoc (attached)For every row in that: Retrieve data from sql server db based on info in the Orange columns of FirstExcelDoc Let's say I retrieved data elements A, B, C, D, and E from sql server. Then I need to enter those same data elements A, B, and C in another excel spreadsheet (which has formulas etc) After inputing A, B, and C in that spreadsheet, read a couple of calculated fields and compare those results to data elements D and E retrieved originally from SQL Server DB. Finally, output the results in the Blue columns of the FirstExcelDoc spreadsheet for that row.Loop through and do the same thing for row 2 of the FirstExcelDoc and keep on until you see "END TEST" in the FirstExcelDoc.

I'm looking for a method of doing this efficiently. I have read several articles over the past few days as well as those from Mike R. but just need some direction to get started on this.To start of I'm looking for whether to read the entire FirstExcelDoc spreadsheet or just read the info for first policy number(2nd row) and process it and write out the blue column info for that row and then loop through and come back and read the second policy number (3rd row) etc... Please attach a code snippet for either way of reading the data.

View 19 Replies View Related

Office Automation :: Orphan Excel Process Started Via Automation

Jun 17, 2009

I'm using excel via interop in application.Sometimes users kill application that created excel instance and that results in excel instance sitting in memory without any chance of disposing it.First I tried to tackle this using ROT(running object table) looks like not all instances of excel are registered there.Than I tried to somehow mark excel process after it is started via interop.[code]This works as long as excel is visible but in my case excel window is invisible.All I need is to somehow mark process that started via automation with the parent PID, so that later I can kill it if parent does not exist.

View 19 Replies View Related

Office Automation :: PPT Automation = Multi-threading And RPC Server Unavailable

Apr 16, 2010

I have successfully automated a PowerPoint Metrics presentation with VB.Net. However, since there were many complicated calculations, it took quite some time to make the 120+ slide presentation - so I recently tried to revamp the application to be multi-threaded.


View 1 Replies View Related

Office Automation :: Word2007 Automation Without Word12 Object Library

Jan 21, 2012

I've got VS2008 and Office2010, but I don't have Office2007. Therefore, I have the Word14 Object Library but not the Word12 Object Library. Will the code that I create for Office2010 automation also work where clients only have Office2007 or will they have to upgrade their office suites?

View 1 Replies View Related

Office Automation :: Excel Automation - Call Rejected

Dec 17, 2010

I have been pulling my hair out trying to fix this.


View 1 Replies View Related

Office Automation :: Excel Automation Causing: Rpc_e_serverfault

Jun 1, 2010

We have a vb program which is run on our server by scheduled task every day. The program opens about 30 excel files, refreshes the data connections, pivot tables and then saves the document in another location.

This may run fine for a couple days but sooner or later the process starts crashing, usually with this error: RPC_E_SERVERFAULT.

My question is, Is it expected that continually opening/closing/refreshing workbooks will inevitably cause the Excel object to crash at some point.

View 3 Replies View Related

Office Automation :: MultiThreading In MS Office 2007 (Excel, Outlook, Etc)?

Mar 28, 2011

i was wondering if someone could give me the final explanation on what i might be doing wrong here.I spent a lot of time reading around the net and the forum about how to add Threading capabilities to a VB project.

Nos, i've got .NET 4 installed, and i've added the system.tsr and mscorlib.dll files as reference in, say, Excel 2007 (see screenshot).However, when i try to make a thread with anything as basic as "Dim Thread1 As System.Threading.Thread", i get a user-defined type not found error.Indeed, when i use the object browser to see what's in the System file, theres nothing remotely linked to any Threading, and in the mscorlib file, nothing under "Threading" either, just a few Thread related functions, but nothing defining a data type

View 2 Replies View Related

Office Automation :: Uninstall Office Shared Addin Programatically?

Feb 15, 2011

I've developed shared addin for Microsoft Word. I distribute this addin with my application and using Inno setup for installation. The Inno setup installs my application and then runs "myAddin.msi" file in order to install addin.

how to uninstall this addin programatically?

Right now, in order to uninstall addin, the user has to to it manually through control panel.

View 2 Replies View Related

Run-time Error '5200' Method 'endMessage' Of Object 'ISoapConnector' Failed

Jul 14, 2009

Run-time error '5200' Method 'endMessage' of object 'ISoapConnector' failed

Dim Serializer As SoapSerializer
Dim Connector As SoapConnector
Dim Reader As SoapReader
Set Connector = New HttpConnector


View 4 Replies View Related

Runtime Error 440: Automation Error?

Aug 14, 2009

I work for Southwire Company. We are owners and developers of a program called SAG10. It is set in VB6. When trying to run this program on Windows Vista, I get a runtime error 440. Not all installs on Vista behave this way. I have had multiple successes in installing and running SAG10 on Windows Vista. I have changed settings to mimic the successful runs and I still get this error. I have disabled the User Account Contro

View 4 Replies View Related

Office Automation :: Method Not Found: Void Excel.Range.set_Value(System.Object,System.Object)

Mar 11, 2009

following error message:

Method not found: Void Excel.Range.set_Value(System.Object,System.Object)

View 4 Replies View Related

Office Automation :: Display Office Documents To Form?

Jul 25, 2010

how do i use the webbrowser to display the word or excel docs. just like the pdf viewer... i tried the webrowser1.navigate but it didnot work, if it does its opening a new window, im using office 2010..

View 4 Replies View Related

Office Automation :: How To Display Office Documents To Form

Nov 27, 2011

How do I use the webbrowser to display the word or excel docs. just like the pdf viewer. I tried the webrowser1.navigate but it didnot work, if it does its opening a new window, I am using office 2010.

View 1 Replies View Related

Office Automation :: Office Add-in For Word 2010 64bit?

Dec 21, 2010

I've made Add-in for Word 2007 in VS2005.It worked well with Word 2007 and now it works well with Word 2010 32 bit.However it doesn't work with Word 2010 64 bit. The installation is successful, but the ribbon button doesn't show up.

Do you have any experience with add-ins for Office 64 bit?

View 5 Replies View Related

Office Automation :: .net Automation Excel App Not Closing

Sep 25, 2009

I'm having an issue where my excel.exe process doesn't close until I close my .net application. I'd like to avoid using Process.Kill() if at all possible.


Private Sub WriteRowsToXls(ByVal rows As DataRowCollection, ByVal xlsPath As String, ByVal showStatus As Boolean, Optional ByVal AddTotals As Boolean = True)
Dim xlsApp As New Microsoft.Office.Interop.Excel.Application


This method references a couple of other methods I use for repeated formatting tasks, I'll include those methods below. (I added the FinalReleaseComObject into the other methods after reading Mike's thread but the issue persists)

Private Sub SetRangeValidation(ByVal rng As Range)
With rng.Validation


Method SetRangeAllBorders does about the same as these other methods but my post is too long to add it. The only other things not shown in these code snippets are a few string variable that are defined in the class, studentWS, studentsWSPW, paymentsWS and paymentsWSPW My App creates an instance of the class, loads some data, runs the method above, and then sets the class to nothing. I'm using .NET 3.5 automating Excel 10

View 2 Replies View Related

Office Automation :: Automation Addin Requirements

Aug 13, 2011

I wrote a simple Automation Addin using VB.NET and .NET 4 and want to distribute it's dll to a

computer with xp sp2 and Office 2007 (Excel 2007) without I install .net on that computer, is it


View 2 Replies View Related

Copyrights 2005-15, All rights reserved