Topics Search

vba to close specific file

vba to close specific file
Views: 61
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:

More topics

 

Drag And Drop File VBA

Preview
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

Preview
I have an open report on the desktop and want to close it with
 

Very First Step In Launching an Application?

Preview
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

Preview
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
 

From Access unable to close Word with VBA

Preview
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.
 

Bypass beforeclose event

Preview
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

Preview
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

Preview
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.
 

Running a Delete (Records) Query on Close

Preview
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.
 

Access 2010 - Open / Close Excel file

Preview
- 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.