Results 1 to 4 of 4
  1. #1
    Snayjay is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2014
    Location
    Gulf of Mexico
    Posts
    10

    Angry Printing Excel from Access (Excel Hidden)

    I am making a db to use for my work. We have some files in a folder, Excel, Word and PDF. I have a table that holds (FORMID, FORMNAME, FORMLOCATION, FORMTYPE) [form type I put there in case I have to do select case code for different options in opening code for different filetypes.

    Anyway, I currently use this code to view my files.

    Code:
    'Open a form to view
        Dim strInput As String
        strInput = DLookup("[FORMLOCATION]", "FORMtbl", "[FORMID] = " & FORMLOCATION.Value)
        Application.FollowHyperlink strInput, , True
        GetUserAddress = True
    The above code works great, it just opens the file. Use this just so when people don't remember the file they need they can view without printing. But for those instances where you know for sure you want to print a particular file, I just want to be able to use the dropdown (FORMLOCATION) and click the button (PRINTbtn) and it prints. I've searched for hours and have found nothing that works. Although I've tried several bits of code, I'm always running into errors I can't figure out.



    Any help would be greatly appreciated.

    v/r

    Snayjay

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I use automation:

    Code:
    Dim xl                 As Object
    Dim strFile            As String
    
    Set xl = CreateObject("excel.application")
    strFile = "PathToFile"
    xl.Workbooks.Open (strFile)
    xl.ActiveWindow.SelectedSheets.PrintOut
    xl.Quit
    
    Set xl = Nothing
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Snayjay is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2014
    Location
    Gulf of Mexico
    Posts
    10
    You rock! Thanks much.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  2. Replies: 10
    Last Post: 12-28-2012, 02:06 PM
  3. Replies: 4
    Last Post: 12-17-2012, 01:21 PM
  4. export query to hidden excel worksheet
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 3
    Last Post: 10-14-2012, 12:39 PM
  5. Problems using VB to run Excel as hidden
    By omahadivision in forum Programming
    Replies: 7
    Last Post: 09-12-2012, 12:34 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums