VBA Code to open Wxcel from within Access

MS Office Access


  • 1. Tracking changes to a table
    I maintain a database that is shared with several other people. My boss has just decided that he would like a report that shows the exact times that changes are made to the main table in the database and what those changes were. Is this possble? I don't know much about programing, so if someone else has done this I could use all of the help you can give me. I am not too proud to copy someone else's work, especially since this seems to be way over my head. Thanks for your help.
  • 2. how can i add and subtract inventory items in access
    Im trying to create a simple inventory / PO database, but i can figure out how to subtract inventory per PO
  • 3. SendObject, Snapshot in Access 2002 and 2003
    I created a DB in Access 2002 that had VBA Private Sub that ran from a Form Button. This button would open a report based on the Form and use the SendObject command to also e-mail it to a recipient. The Sub is below. Private Sub ReprintEmail_Click() On Error GoTo Err_ReprintEmail_Click Dim stDocName As String stDocName = "InvoiceOrderNum" DoCmd.OpenReport stDocName, acNormal DoCmd.SendObject acReport, "InvoiceOrderNum", "SnapshotFormat(*.snp)", " XXXX@XXXXX.COM ", "", "", "Appliance Sales Order ID " & Forms!ReviewOrders5![OrderID], "", False, "" Exit_ReprintEmail_Click: Exit Sub Err_ReprintEmail_Click: MsgBox Err.Description Resume Exit_ReprintEmail_Click End Sub I never had any problems and the code worked great until I recently got a new PC with Office 2003. I did some modifications on the DB for something else that did not pertain to this code at all. My co-workers are still using Access 2002 but I am using Access 2003. When this button is clicked in 2002 it immediately comes up with a parameter box asking for a format which has not been an issue until I got the new Office 2003. I have changed the 'Format' to all of the following with no luck: "Snapshotformat (*.snp)" , "Snapshot Format", "(*.snp)", acformatsnp, and "Snapshot Format (*.snp)". My co-worker and I think it has something to do with the Object Library reference. Please help. Thanks, JBB
  • 4. Opening forms report in ADP from MDB automatically
    I using an ADP as a main front end, sql server as database house and MDB as temp import. Currently right now, i have it user click on button and the MDB opens up, but it is hidden (don't want them to see the process of import) and then after import, it closes itself (MDB). I need a way before it closes it self, to open up a form in ADP and then closes it self. Wonder if it is possible also, wonder if there is a way that the MS access splashscreen doesn't show up with teh MDB opens. thanks
  • 5. Opinions please.
    When you install windows in a directory other than C:\windows MSoffice installs differently too. For example, My computer OS is installed in C:\WINDOWS and two computer in the clearning dept have thier OS installed in C:\WNNT. because of this OFFICE is installed differently. That does not seem like a problem untill you read the rest of this message. All three computers have XP Pro and OFFICE 2002. System 1: OS = C:\WINDOWS OFFICE = C:\PROGRAM FILES\MICROSOFT OFFICE\... System 2: OS = C:\WNNT OFFICE = C:\MICROSOFT OFFICE\... System 3: the same as System 2 The problem: On my system (1) the reference to "Microsoft Excel 11.0 Object Library" does not exist on systems (2) and (3). However, "Microsoft Excel 10 Object Library" does exist on system (2) and (3) but not on system (1). Is there a way to Programmicly connect a Reference library to a program. Could I set the "Microsoft Excel 11.0 Object Library" on a network drive then set the EXPORTXP.MDB to look at the above library? I understand that the registry entries should fix this problem. I just don't know how to set registry setting manuall. Your Opinions please.

VBA Code to open Wxcel from within Access

Postby Um9kIE1hbnNvbg » Wed, 02 Jul 2008 21:49:04 GMT

Hi, can anyone help please . . I thought it would be quite straightforward ..

I want to write the code to open an excel spreadsheet from with Access. I 
can see how to do it with the RunApp Action in a macro, but not in code.


RE: VBA Code to open Wxcel from within Access

Postby RGVubmlz » Wed, 02 Jul 2008 22:19:00 GMT

I asssume you mean the Excel spreadsheet already exists and you want to open 
it, Edit it and re-save it ? If Yes, use something like this

Function Open_Excel_File()
    On Error GoTo Excel_Error
    Dim xlApp As Excel.Application
    Dim xlWS As Excel.Worksheet
    Set xlApp = New Excel.Application
    If xlApp.FindFile = True Then
        Set xlWS = xlApp.Worksheets(1)
        ' your code here to do stuff on the worksheet
        xlWS.SaveAs xlApp.ActiveWorkbook.FullName
        Set xlWS = Nothing
    End If
    Set xlApp = Nothing
    Exit Function

    MsgBox Err.Description
    Set xlWS = Nothing
    Set xlApp = Nothing
End Function

Re: VBA Code to open Wxcel from within Access

Postby Stuart McCall » Thu, 03 Jul 2008 00:24:51 GMT

Application.FollowHyperlink "C:\FolderName\FileName.xls"

Similar Threads:

1.Opening OLE Object Sync Issue within VBA Code

I have a Table with OLE object in a field of the table.  I use a form with 
the table as its RecordSource.  When I Activate the OLE object in the form, 
the first time, the VBA code doesn't advance until the OLE object is open 
(Visio in my case).  When the program loops, the second time, the VBA code 
doesn't stop for the OLE to be open.

This is my code:

   Do Until rs.EOF
        Forms![GenPPT]![OLEFile].Action = acOLEActivate
        Set AppVisio = GetObject(, "visio.Application")
        Set DocObj = AppVisio.ActiveDocument

        More VBA Code Here

        More VBA Code Here

        Set AppVisio = Nothing


The problem is as follow:

1)    When the VBA Code first Activate the OLE in my form, it waits until 
the OLE (Visio) is open before moving on in the VBA Code.

2)    After the first time, when it loops back, the VBA code advance to the 
first "Stop"  while the OLE is activating in from the Form.

3)    I see this issue with Acc2000, 2003, and 2007.  I am using XP sp2 OS.

Can someone tell me how I can sync them up or is there something I am doing 

Thanks You,


2.How to code VBA to open "Open File Dialog Box" in MS ACCESS 2000


My client is still running MS ACCESS 2000, and no plan to move forward to
2003 yet.

Is there a similar code to "With
Application.FileDialog(msoFileDialogFilePicker)" in MS ACCESS 2000 ?



3.Opening an Access db within vba


Can anyone tell me the best way of opening an Access db from within the vba 
code of another Access db? The db I want to open is protected by user-level 
security with a .mdw file.

Basically I need to circumvent the usual Logon Name / Password process when 
opening a workgroup-protected .mdb and replace it with a single form, 
non-protected Access file which opens the new db with correct user name and 
password parameters. At the moment I am doing this by executing a Shell 
command within the vba, but I wonder if there is a better way to do this.

If there isn't, can anyone tell me if there is a way of knowing if the Shell 
command executed successfully?

Many thanks,


4.Compressing an exported file within VBA Code

I am using MS Access 97 on an XP machine and was wondering how I can call the 
built  in XP compression (zip) application from within VBA code?  Due to 
space limitations I export a large chunk of data everyday to a comma 
delimited text file and would like to automatically compress the exported 
file to save disk space.


5.Simple VBA code to open other access database

I am trying to open another access database from a form, what is the
simplest way to do that.

6. opening excel sheet in access VBA code

7. Running Macro from within VBA Code

8. Running VBA code within a Macro

Return to MS Office Access


Who is online

Users browsing this forum: No registered users and 31 guest