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


ADVERTISEMENT

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

[CODE]...

View 8 Replies

Runtime Error '424' When Executing FileSystemObject.CopyFile In Script In Excel 2007

Sep 23, 2009

In my office they installed Office 2007, since then I am having several problems with my macros / VB script routines, in this occasion I am trying to use the FileSystemObject.CopyFile function to copy several files from one directory to several directories depending on the files code.Based on the file's code I build the destination path and then I try to copy my files from the original path to destination path, but when executing this sentence I receive an error message that says "Run-time error '424' Object not fund".

Sub prepara_2007()
Sheets("IngresoBD").Select
Range("I5").Select

[code]....

View 2 Replies

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

[code]....

View 1 Replies

.net - Optimizing Loop For Vba Macro Excel 2007?

Sep 9, 2011

I have this code that works. it goes down a range and deletes the empty rows, seperates the first character into a different column if its not a number or negative sign.This code WORKS. but it is too SLOW for the amount of data i need it to deal with. I have already turned off automatic calculations. screen updating.and visibility of application.

[Code]...

View 3 Replies

Optimizing Loop For Vba Macro Excel 2007?

Dec 28, 2011

I have this code that works. it goes down a range and deletes the empty rows, seperates the first character into a different column if its not a number or negative sign

View 1 Replies

Excel 2007 Macro Opens Access Db But Then It Disappears?

Sep 24, 2009

This code worked fine in Excel 2003, but since upgrading to Excel 2007 (Office 2007) it's not working. In Excel 2003 it opened the access db form and stayed open. In Excel 2007, you can see the db open, then the form, but then it immediately closes. I've checked to code and it still works fine in 2003. Can anyone tell me how to fix this? Here's the code:

Sub OpenDatabase()
Set a = CreateObject("Access.Application")
strDB = "C:Weekly FilesWeekly Db.accdb"

[code]....

View 4 Replies

Office Automation :: Run Excel 2007 Macro From Custom Button

Jun 10, 2009

I have used Visual Studio 2008 (VB) to create a custom tab and button group with custom buttons. When any of those buttons are clicked, I simply want to run a macro (add-in) that will already be loaded when Excel is launched. The main examples I've seen create an Excel object in the VB code and then call the macro, but that seems like unnecessary overhead, since the custom buttons are are already loaded into Excel.

[Code]....

View 5 Replies

Error Opening Excel File From .net 2010?

Aug 26, 2009

Dim excel As New Microsoft.Office.Interop.Excel.Application()
Dim wb As Microsoft.Office.Interop.Excel.Workbook = excel.Workbooks.Open(txtFileLocations.Lines(w))
Dim ws As Microsoft.Office.Interop.Excel.Worksheet = TryCast(excel.ActiveSheet, Microsoft.Office.Interop.Excel.Worksheet)

when the program tries to opens an excel file, it always throws me an error "Office has detected a problem with this file. Editing may hard your computer" and my program crushes.......The problem appears on the SECOND line, on DIM wb...blahblah.. i went to the office and unclicked the "protected view" checkboxes.. but it still throws me those errors. my guess is that the office i have in the computer is not the same as the one that my program uses to open excel files (i mean, i loaded/imported some excel.dll files in the program so i guess that will be the one) But how do i make the program not care if the excel file is "potentially dangerous"?

View 3 Replies

Error Opening Excel File From 2010

Jul 26, 2011

[Code]...

when the program tries to opens an excel file, it always throws me an error "Office has detected a problem with this file. Editing may hard your computer" and my program crushes. The problem appears on the SECOND line, on DIM wb.

[Code]...

View 14 Replies

RPC_E_SERVERFAULT Error On Opening An Excel File In Asp.net

Apr 13, 2011

I'm trying to open an Excel file to get and set some values. Unfortunately, I have no choice, I must to work with Excel.

Dim xAp As New Microsoft.Office.Interop.Excel.Application
Dim xWkb As Microsoft.Office.Interop.Excel.Workbook

xWkb = xAp.Workbooks.Open("c:uploads este.xls")

Always I have this exception: (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

Need I Excel installed in server machine to open Excel files? I don't think so, because when I create a new application and workbook throught code, all things go right, but... its a possibility...

View 1 Replies

Error Opening Excel File Read Only ODBC?

Sep 25, 2009

Error Opening Excel File Read Only ODBC

View 1 Replies

Opening Spreadsheet Using Oledbconnection Is Crashing When Using Excel 2007 Files?

Sep 8, 2009

I've got a little app that uses oledbconnection to extract data from an Excel spreadsheet. I need this app to support .xls and .xlsx files. The app runs fine when I give it a .xls but when I select a .xlsx it crashes with an exception on my cn.Open command.

View 1 Replies

Another OPTIMIZING Macro Vba Code For Excel 2007 - The Code Is A Sort Of Transposer For Data

Sep 9, 2011

this code was not done by me originally and there are some thigns here i dont quite understand i have altered it a bit from my coworkers code to suit my data and it works. but too slow. and when i have 4000+kb excel files it might freeze altogether. ( I have checked tho that when and after this transposer runs it will still be within the excel row limit, i had done calculations before and made a macro to automatically split excel files based on number of columns and rows to make sure this is so ). This code seems to start out fast then goes slower the longer it runs. at least this is what it seems liek to me.

[Code]....

View 2 Replies

Convert Excel 2007 Macro Code To Correct VB 2008 Code?

May 26, 2010

i recorded the following macro in excel 2007:

[Code]...

View 3 Replies

SQL Server 2008 FileStream And Excel 2007 - Errors In Opening The Spreadsheet?

Feb 12, 2010

I am having a problem with using the SQL Server 2008 FileStream function with an Excel 2007 spreadsheet. I can store an Excel 2003 format spreadsheet and bring it back with no problem. When I bring the Excel 2007 format spreadsheet back from the DB I get a message that there are errors in opening the Spreadsheet and the Excel App asks if I want them repaired before it is displayed. I answer yes and the Spreadsheet is renedered perfectly. Could this be a FileStream problem or an Excel 2007 problem?

View 11 Replies

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'.

View 2 Replies

VS 2005 : Error In Opening An Excel File : Old Format Or Invalid Type Library

Feb 24, 2012

I am trying to open an Excel file using the following commands:

xlsWB = xlsApp.Workbooks.Open(filename, , True)

where 'filename' is the name of the file.However I am getting the following error message:

Message = "Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))"

I originally developed an application where I used the above code with default language setting of "English" (under regional and language settings). When I am changing the language setting to "French", the above errror comes up. I am changing the language setting to French in order to simulate an error when this application is run in a French version computer.

View 3 Replies

Insert Macro Into A Excel File Without Using The Excel Com Library?

Aug 30, 2010

Is there any way to insert an existing macro into a existing excel file without using the excel library ? I need this to set the excel to print whole work book .I cannot use excel library because it will be done online in the server where installation of excel is not possible. I can however use the c#.net coding . I am using NPOI to generate the excel.

the macro is given below

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If printed = False Then
Cancel = True

[Code]....

View 1 Replies

Why The Excel File Not Opening Using This Code - Error - ExcelConnection.Open()External Table Is Not In The Expected Format

Apr 17, 2012

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" + fileName + "'; Extended Properties=Excel 5.0"
Dim ExcelConnection As System.Data.OleDb.OleDbConnection
ExcelConnection = New System.Data.OleDb.OleDbConnection(ConnectionString)



Error occurs on line ExcelConnection.Open()External table is not in the expected format.

View 2 Replies

Quit An Excel Macro Externally (from A GUI Not From Macro)

Oct 21, 2010

I'm have a program (GUI) that interfaces with excel to execute macros. We're using Microsoft.Office.Interop.Excel to call/run the macros and this works great.What I can't figure out is a good way to cancel the macros from the GUI.One idea we had was to use the excel.application variable that runs the macros to write a "stop" value to a specific cell in the workbook, and in the macros (they are all mostly loops), check for the "stop" value in that cell. This crashes my GUI with this The program '[2188] BVLReports.vshost.exe: Managed' has exited with code -336589910 (0xebf00baa).And excel gets tied up, and won't respond. I know how to Exit Sub from within the macro if the "stop" value exists, so I don't need answers on how to check/cancel from inside the macro. Any ideas on a better way to write this "stop" value or a better way to cancel the macros externally?

View 2 Replies

VS 2010 Excel Method Find In VB2010 - Convert Excel Macro In A Exe File Using Visual Studio 2010

Oct 25, 2010

I decided to to convert my excel macro in a exe file using visual studio 2010. In excel macro method find is present like this:

[Code]...

View 9 Replies

Opening And Saving Word Doc - Error When Visibility Turned Off?

Jun 11, 2011

I am opening a word document and saving it as html with the following code. If i set the objWord.Visible = False , i get an error: Exception from HRESULT: 0x800A1098 , which i believe indicates there is nothing to open.

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim objWord As Microsoft.Office.Interop.Word.ApplicationClass = New ApplicationClass()
If Not (fUpload.HasFile) Then

[code].....

View 2 Replies

VS 2005 Opening And Saving Text Files Error

Jun 11, 2009

A query concerning opening and saving a file.i have two commands, one the opens and another that saves [the same file].i'm using the StreamReader and StreamWriter methods.issue is this:if i comment out the open code, the save works fine.if i comment out the save code, the open works fine.if i let both run together, i get an error, usually with the save saying that the file could not be accessed. note, before anyone asks, i do close the file after saving or opening what could be the problem? open works fine, because it usually happens prior to the save, and then save process cannot access the file..?

View 3 Replies

Create A Form With Which The Opened Excel File And Allow It To Manage (as The Macro Commands)

Aug 25, 2009

I using Microsof Visual Basic 2008 Express Edition. I need to create a form like: 2 buttons are open and save existing .xls file which each generation can choose a different.2 textbox that can be entered on the column
and last button to when choose two columns, to find duplicates values and mark different color same values. Is it possible?

At the moment Excel file opens, but the comparison does not require the introduction of the columns

View 1 Replies

Print Excel File Form Without Opening Excel?

Jul 4, 2005

How to print excel file form vb .net without opening excel?

View 9 Replies

Save An Excel File After Opening Excel Application?

Jan 28, 2010

i'm trying to save an excel file after I open my excel application. This is what I have so far:

'Opens the report
xlPeakDemand.Visible = True
xlPeakDemandWorkbook.SaveAs("C:Documents and

[Code].....

When saving as an xls it works fine but when saving as a htm its a disaster Just a bunch or symbols and stuff. BUT if I go into my xls document and Save As webpage from there, it works fine!

View 2 Replies

Run-time Error 1004?

Jun 17, 2011

this is my code and it doesn't work of course , do you see some error ??

Dim i, j, z As Long
i = 3
j = 3

[code]......

View 2 Replies

Automating Process Of Opening MPP File And Saving It As CSV?

Mar 12, 2012

I need to find a way to automate the process when a user uploads a microsoft project file to a web application I already have created. The process will need to basically use the save as from project to save into a .csv file so I can use this to import the data to an SQL database (this is needed for custom reporting we already have set up using SQL). I need to automate this process because I will be receiving tons of project files, and if the process is automated the users will then be able to instantly see results.

Basically, is there any way to create or run an automated process that will save these project files as .csv files? Even if the csv files are not formatted correctly, I can find a way around that, just need to first get them into .csv files. The only way I could think of this is to follow the instructions listed below, but I would then need to automate a process to open the file and hit save so this works... [URL]

View 1 Replies

Opening Excel In Program Error

Sep 24, 2009

What do you think is wrong with the commented line in my vb.net code below? it returns the error message "member not found".[code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved