473,416 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Run-Time Error 1004

I have a bit of code tied to a command button in Access that runs a
query then transfers it to a new Excel worksheet (& new file). It
works fine EVERY OTHER
TIME THAT I RUN IT....what the 'heck is going on? I get the following
error message on the odd runs:

Run-Time Error 1004

Method 'Columns' of object '_Global' failed
.....the query results make it to the worksheet. The error occurs in my
section
of code that formats the worksheet once the data has been imported. I
have copied the applicable section of data below:

THIS IS WHERE I GET THE ERROR (EVERY OTHER TIME THAT I RUN IT)
Columns("A:A").EntireColumn.AutoFit
Rows("1:6").Select
Selection.Insert Shift:=xlDown
Range("A6").Select
ActiveCell.FormulaR1C1 = "Group Name"
Range("B6").Select
ActiveCell.FormulaR1C1 = "FSC"
Range("B6").Select
ActiveCell.FormulaR1C1 = "FSC #"

....and so on.
Is there something I need to define beforehand? Any assistance w/ this
would be GREATLY appreciated (I can't afford to lose anymore hair).

Nov 13 '05 #1
2 14907
I've often gotten this error when I already had an instance of Excel
running.
When you finish with this portion of your code, do you explicitly close all
your Excel objects, Quit your Excel application, and set all Excel objects
to Nothing?

"dailem" <mi*********@ucphysicians.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I have a bit of code tied to a command button in Access that runs a
query then transfers it to a new Excel worksheet (& new file). It
works fine EVERY OTHER
TIME THAT I RUN IT....what the 'heck is going on? I get the following
error message on the odd runs:

Run-Time Error 1004

Method 'Columns' of object '_Global' failed
....the query results make it to the worksheet. The error occurs in my
section
of code that formats the worksheet once the data has been imported. I
have copied the applicable section of data below:

THIS IS WHERE I GET THE ERROR (EVERY OTHER TIME THAT I RUN IT)
Columns("A:A").EntireColumn.AutoFit
Rows("1:6").Select
Selection.Insert Shift:=xlDown
Range("A6").Select
ActiveCell.FormulaR1C1 = "Group Name"
Range("B6").Select
ActiveCell.FormulaR1C1 = "FSC"
Range("B6").Select
ActiveCell.FormulaR1C1 = "FSC #"

...and so on.
Is there something I need to define beforehand? Any assistance w/ this
would be GREATLY appreciated (I can't afford to lose anymore hair).

Nov 13 '05 #2
Well it took a lot of trial & error, but I finally got it working
correctly. I'm a rookie at VBA, so I had to dig a little further into
how to best accomplish what you suggest in your reply. I actually
modified my code to always refer to ranges or selections w/ the preface
of excel.application.....this eliminated excel.exe running even after I
shut the program down.
I appreciate your feedback to point me in the right direction.

Thanks Again MacDermott..............Mike D.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: James | last post by:
Hi, I would like to run a custom script on a linux box via a button on a php page (php webpage hosted on the same linux box). Is this possible? If so , can you give me a pointer in the right...
3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
2
by: Jenna Olson | last post by:
Hi all- I've never seen this particular issue addressed, but was wondering if there's anything to support one way or another. Say I have a class: class ManipulateData { public:...
2
by: Napo | last post by:
Hi: i build a .net application named A.exe. I need run this application twice using c# code in another application. i try to use process.start(A.exe) twcie, but it failed. Because the second...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.