There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows vista windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Object Variable Error using Access VBA


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
pldwilli's Avatar
Junior Member with 17 posts.
 
Join Date: Feb 2004
23-May-2004, 10:48 PM #1
Object Variable Error using Access VBA
I am currently working on an access program that will take info from several different places (html reports, spreadsheets, other databases). I am currently trying to get access to import an excel spreadsheet using vba. I wrote a vba auto macro for excel to grab info off of a report in HTML format. My spreadsheet works great, however, when I try to use access to open the spreadsheet then run the macro and then import, I get an error. "Object variable or with block not set". the block of code that keeps hanging is in my excel spreadsheet macro and is as follows

With Application.Cells
.Find(What:="** END-OF-JOB **", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True).Activate
End With

My Access VBA code

Dim appXL as New Excel.Application
Option Compare Database
Option Explicit

Public Sub ImportExcel()
Set appXL = CreateObject("Excel.Application")
appXL.Workbooks.Open "Path to my file"
appXL.Activeworkbook.RunAutoMacros xlAutoOpen
DoCmd.RunMacro "Import Report"
appXL.Quit
Set appXL = Nothing
End Sub

My code runs fine in excel, but when trying to run through access it just does not want to work. I have tried everything I can think of, any help on this would be greatly appreciated. Oh by the way I am using excel 97 and Access 97
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:57 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.