vba to close specific file

I have an adobe file that I constantly 'print' from access so that the most resent data from a report is available. This file stays open all the time (to be displayed on a projector) until it has to be reprinted. I would like to be able to put this on a timer so that the file will close, reprint, then open again all automatically. I have this all completed except for the closing part. For the life of me I cant find the code to close a specific file using vba code.

My pathway for this file is:
C:\Documents and Settings\User1\My Documents\Rpt_Qry_Tbl_Data.pdf

Any help is welcome (or to at least know if this is even possible from access)

Sponsored Links:

Related Topics

Drag And Drop File VBA
I want to be able to drop a file into a specific are of an access form that will trigger VBA to save that file into a specific directory and rename it with data from fields in the open form.

Can anyone point me in the right direction on what control I might be able to use that will allow an Access form to recognize that a file is being dropped into it, 'take control' of thefile and kick off the appropriate VBA to save the file out to where I need it stored?

Secondly, once I have this down I'd like to know how to have a link to the file auto populated in a field of that same form.


close a specific report with VBA
I have an open report on the desktop and want to close it with


Very First Step In Launching an Application?
I just recently upgraded from Access 97 to 2007. Our department inherited and application program programmed in Access (user interface for extracting specific data) that was programmed by somebody else using lots of VBA code.

There are only 2 things suprisingly that are not functioning 100%. What I would like to know is what is the first command that happens when I double click the application to launch it. One issue I have is a form is launched that I always have to close out before I can use the application properly.

I want to see if I can either remove that pesky form from lauching or moving it down later in the sequence so I don't have to close it everytime.

Also, I placed the application and supporting files in the "Trusted Location", but I am still asked to "enable" the file before I can launch it.

I have about 3% knowlege of VBA programming BTW


How to close a spreadshee without Excel message
I have a macro to export an Access table to a text file. Then I use an Excel macro to open the text file and copy/paste to an Excel template. In the Excel macro, I write a code below to close the text file:

Activeworkbook.close

The Excel prompts a standard massage with 3 buttons: save, notsave and cancel. Everytime, I click the notsave button to close the text file.

Is there a way to write some codes to bypass this standard message? What I want is to close down the text file without any change


Bypass beforeclose event
So I am pulling data using code out of excel from access.

When I am done, I use the .quit or .close, but the excel file has a before close event that brings up a special msgbox.

How do I bypass the before close event. I dont want to save the file or anything, I just want to close excel without the before close event running


Bypass beforeclose event
When I am done, I use the .quit or .close, but the excel file has a before close event that brings up a special msgbox.

How do I bypass the before close event. I don't want to save the file or anything, I just want to close excel without the before close event running.


From Access unable to close Word with VBA
Using Microsoft Office 2007, and Windows XP. In Access 2007 a Word document is created, text is added, and Word closed with VBA. Then unable to open the document because it is 'locked by user'.

Dim wo As Word.Application
Dim path As String

Set wo = CreateObject("Word.Application")
wo.Documents.Add
wo.ActiveDocument.SaveAs FileName:=path

'Text added to the document

wo.ActiveDocument.Save
wo.ActiveDocument.Close False
wo.Quit
Set wo = Nothing

The code is successful in creating the document and when looking in the directory, the file is there but with ~owner's file. When attempting to open the file with VBA, the message statesthe file is locked by the user who created the file.


From Access unable to close Word with VBA
Using Microsoft Office 2007, and Windows XP. In Access 2007 a Word document is created, text is added, and Word closed with VBA. Then unable to open the document because it is 'locked by user'.
Dim wo As Word.Application
Dim path As String

Set wo = CreateObject("Word.Application")
wo.Documents.Add
wo.ActiveDocument.SaveAs FileName:=path

'Text added to the document

wo.ActiveDocument.Save
wo.ActiveDocument.Close False
wo.Quit
Set wo = Nothing
**********End of Code******************

The code is successful in creating the document and when looking in the directory, the file is there but with ~owner's file. When attempting to open the file with VBA, the message states the file is locked by the user who created the file.


Access 2010 - Open / Close Excel file
- I am using MS Access to Export date to an excel file using a macro. The command is ImportExportSpreadsheet and then transfer type is Export.

This works fine, however since this runs daily the size of the excel file increases each time.

If if manually open the excel file and then close it straight away the file size drops from 160 meg to 60meg (as an example).

I was hoping to add another macro command that would just open the excel file and then another to close the file, however I can't seem to find one.


Find path of file in different folder than the current Database
Is there any way to find that path of a file that does not exist in the same folder as the database? I have been looking around and I've only found ways to find file names in specific paths. When I hand over the database to the user, I'm not sure if they'll keep the two files (the Database itself and an excel file) together, so I want to eliminate coding a specific path (or CurrentProject.Path) into my vba


Running a Delete (Records) Query on Close
I have no experience with VBA (which I am thinking may be the only solution to this problem) but I want to be able to have Access (2003 or 2007) run a Delete Query of this one table right before someone decides to close down the database. The reason for this is that the only way autonumber will reset is if you delete the records in a table and compact the database. The compacting portion was already set within the options menu, but now I am looking to have all records deleted on close. Can someone help me out? Also, if VBA is the only way, can someone walk me through on how to accomplish this. I have yet to begin teaching myself VBA or SQL.


Pulling Specific Data from Excel
I have a database that needs to pull specific data from Excel.

Specifically, one specific Access field should go directly to a specific
cell in Excel and get that value.

I'm thinking that I use some kind of VBA code to open my
Excel file and assign the cell contents to a variable
which I then use in Access. I think I can find the cell
in Excel using a named range.

I need the exact code, though.


How do I open another database using VBA?
so this relates to some access updating questions I've been asking. I went to that AutoFEUpdater site and read through it, and it all seemed a bit complicated and required too much user interaction. I'm dealing with non-pc literate people here and I'd like to make the whole thing program driven.

I saw an alternate solution on the website that involves opening a separate updating database, using that database to automatically replace the old file with the new file, then reopening the database. The updater program works fine, but I'm having a hell of a time trying to figure out how to get the program to open using a command button.

I've been doing research and it seems that the "shell" command is supposed to be used, but none of the places I've looked show how to actually use it. They only talk about the problems they have. What is the syntax for using the shell command? Am I supposed to have a specific reference set up in my VBA?

I'm so close, just can't open the damned updater


VBA Code To Global VBA
s I have a question about saving VBA As Global Module.

While working with Access and VBA There are many VBA codes which we use very frequently for example:
Private Sub close_Click()
DoCmd.Close
End Sub

How to save this as Module and then call to a button


Invalid or unqualified reference
My question is more general than specific. Yes, I am getting the error mentioned in the Title. The full text of the message is:

The expression On Close you entered as the event property setting produced the following error: Invalid or unqualified reference.
This is from an Access project that I inherited. To make it worse, I think that I may have simply fat-fingered the VBA file somewhere, but this error does not tell me where, and this happens immediately when I try to go into Design mode.

Is there any other information I can get (or something I can do) to find out exactly where/why Access (2007) is unhappy?


Excel remaining open after many varying attempts to write quit via Access VBA
Which outputs a couple of reports, then opens one back up to re-format in excel and save/close. It all looks great, but two things happen.

The first is that after running successfully the first time, when trying to run again it falls over and gives me the 'run time error 91 object variable or With block variable not set'

I then debug and it takes me to the line I have shown in red.

I then close the excel sheet which has opened, manually, and close the debugger, and run the report, which then works. (however, I can see from task manager that excel is remaining in RAM,hence if I try the access VBA again it falls over)

Whats missing from my code to get Excel to close properly each and every time the VBA executes!?


Transfer Database
I am trying to do the same thing as saving the Database using the Save As pull down with VBA code.

I have looked for examples on the web but nothing comes close.

Here's what I want to do:

Transfer all the tables (structure and data), form, reports, vba code everything to another accdr not accdb file on a local pc machine.
I want the user to pick the location on their local machine to save the file(I know how to do this).

Is this doable? Is so may I see example code using
DoCmd.TransferDatabase


Killing open applications using VBA
I am using the following code on closing a form in access to kill excell

Set oWS = Nothing
If Not oWB Is Nothing Then oWB.Close
Set oWB = Nothing
oExcel.Quit
Set oExcel = Nothing

all is fine and dandy and it does as I want it to do with the exception that on exiting I get a message box asking if I would like to save the changes to the excel file that is about to close.

I haven't made any changes and wouldn't be doing so, so the question is how do I inhibit the save changes message box so that I never see it, using access vba, a modification to the above code would be nice


Open and close an external Access file
What I want to do is set a backend database to compact on close.

Then close it from a seperate front end database. and then reopen it. all programmatically


Close WORD question using late binding
I have a routine where, with late binding, I open a WORD file and move focus to it, all from within Access (2010). It is up to the user to close the Word file when finished looking at it.

My question has to do with the code that opens the file. If this were a ADO call and I was opening a dataset, I would I would issue a objRef.close and set it to nothing. But what about this circumstance?

Theoretically, since this code is called from a sub routine, the sub routine should do all the cleanup.