+ Reply to Thread
Results 1 to 3 of 3

Accessing Excel objects in Access VBA script

  1. #1
    Registered User
    Join Date
    02-09-2012
    Location
    Lithuania, Vilnius
    MS-Off Ver
    Excel 2007
    Posts
    3

    Unhappy Accessing Excel objects in Access VBA script

    Hello there,
    How's the day going?

    Recently I've been creating Access modules that open Excel files and does some processing prior the importing shoots out.
    The problem I am having is that Access does not really allow me to access Excel object library properly.

    I am using this code:

    Dim Excel_obj as Object
    Set Excel_obj = CreateObject("Excel.Application")

    This works fine as long as I don't try to access something like this:
    Excel_obj.Range("A1").Pastespecial xlPasteFormats

    But it works if I do this:
    Excel_obj.Range("A1").PasteSpecial

    Does anyone know, what cen be preventing me from accessing deeper?
    Also I am receiving error if I try to declare this:
    Dim Excel_obj as Excel.Application
    Error: User-defined type not defined

    Thanks a lot in advance!

    Modestas

  2. #2
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Accessing Excel objects in Access VBA script

    Hi...Have you enabled the Excel reference library?

  3. #3
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Accessing Excel objects in Access VBA script

    It seems to me that you are missing a step. When opening a Word document from Excel, one must set an object to Word.Application and then one must open a Word document. In the code above, you set an object to Excel.Application, but where have you opened an Excel workbook?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1