Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Open, Edit and Print Excel spreadsheet from Access VBA

Featured Replies

Hey guys! It's been a LOOOOONNNNGGG time.

Anyways, I'm trying to figure out how I can program a button in Access with an On Click event that will:

1. Open a file in Excel

2. Select a worksheet

3. Enter some some data from form fields in Access

4. Print the document

5. Close Excel

Anyone have any insight into this? I have found a lot of information by doing a google search, but none of it quite fits what I'm trying to do. I can successfully do this with Word, and the coding it's very similar to what I'm seeing for Excel. Thanks for your help.


Long time no see. You should pop in more often.

Try this as a module to run from a button click:

Sub Run_Excel()
Dim appexcel As Object
Set appexcel = CreateObject("Excel.Application")
'Open Workbook, replace Devlist.xls with your filename
appexcel.workbooks.Open "devlist.xls"
appexcel.Visible = True

'Select Sheet1
appexcel.Sheets("Sheet1").Select

'repeat as needed
' Select Cell to input data into
appexcel.Range("A2").Select
' Get data from table dlookup(Value field, table, criteria)
appexcel.activecell.Value = DLookup("[ID]", "Sheet1", "[ID]=2")

'Set print area
appexcel.ActiveSheet.PageSetup.PrintArea = "$A$1:$K$2"
'Print document
appexcel.ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.