Modules & VBA :: Function To Unzip A File To Same Folder
Jun 26, 2014
I'm trying to write a function to unzip a file (working off Ron de Bruin's code here)..The function should take the path of the zipped file as an argument and return the path of the unzipped file (extracting to the same folder)
Code:
Public Function UnZipFile(strFile As String) As String
On Error GoTo ErrorHandler
Dim objFSO As Object
Dim objShellApp As Object
Dim strUnzipped As String
[code]...
But the code has no effect (i.e., I'm still left with just the zipped file in the folder, not the unzipped contents?) strFile is a legitimate path to an existing .zip file which contains a zipped .xls file
...but found that the .Count property was 0?I've done several searches on how to unzip files using VBA and this seems to be the universally accepted method.
How to search for a file using the dir function, however, i need to search for a file from a main folder which may have several sub folders.
I am having no luck so far - i understand there is a recursive search facility but im not sure how i can get this to work with what i am trying to achieve.
This is the code i have for the dir function:
If Len(Dir("as-tamworth-50midlands.qa$TamworthLaminate C of CsCircuit Foil" & CofC & ".")) = 0 Then MsgBox "This file does not exist" Else MsgBox "Yippee" End If
I have a macro in access that will create a folder and create a word doc in the folder with the name of the folder. I would like to add to the same folder an excel file. The excel file is in a folder and needs to be copied every time in a new folder when created. where to add the excel file from the below folder:
C:Excel CopyCombine_PDF.xls
this is the macro:
Code:
Private Sub Command22_Click() 'this will register the letter and create folder, word doc and open all Me.[DateRegistered] = Date Me.[PersonRegister] = Environ("Username") Me.Refresh
I am trying to display an open file dialog window so that the user can pick up a file. I wish the window to show a specific folder. How can I do this? The code I am using is below. The parameter InitialFileName has no effect on the outcome.
Code: Function GetFileName(strPath As String, imtype As String) As String On Error GoTo Err_GetFileName Dim Dlg As FileDialog Dim sfl As FileDialogSelectedItems Dim sflitem As Variant Set Dlg = Application.FileDialog(msoFileDialogFilePicker)
I am using MS Access 2010. I have a code that I am using that loops through a folder gather all the names of the files in the folder and inserts them into a table (shown below). The table is named "tblFiles" there are two columns in the table titled file name and file path. What I want to do is to also loop through the same folder to find the file path of the files and insert them into the file path column has a hyperlink where users can just click on the hyperlink and the file opens.
Private Sub Form_Load() Dim fs, f, f1, fc, s Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("tblFiles")
I have the code below and I want it to open a file from my documents folder. The only problem is that every computers path is different to this folder. Any easy way to work around and open a file in My Documents without the full path?
I want to eliminate the part of the path in red and make it universal because computers will have a different number.
Operating System: Windows 7
Code below:
Public Function AddITARPicOffloadAnalysis() Dim xlApp As Object Set xlApp = CreateObject("Excel.Application") With xlApp Dim wb As Object Dim ws As Object Dim Lastrow As Long
In VBA I have set a timer on a form to run a query and export to a specific folder as an excel file.
If I open the database as 'File Open' and open the form and let the timer run it exports perfectly.
As soon as I put the database into runtime - the Timer code kicks in and starts running but as soon as it hits the export line. It stops and then does nothing
I have a table with an attachment field called email, where a .msg file is stored for each record. Looking for code to save this contents of this field in a folder in my drive.
I'm currently working on a database to track and inventory documents in my organization similar to a library catalog, but with a digital archive as well. I'll need the ability to "attach" documents to records in the main inventory (though using links instead of storing it in the db) and have the documents live in a centrally accessible location on our shared server.
I will need to have this function work through a few different tables and in a few different iterations, but I'm trying to work on the simplest part first, which is attaching a thumbnail/preview of a given document to the record for that document.
I've got some VBA working well which opens the file picker and copies the file to a directory relative to the DB. It also creates a folder with each employee's ID number if it doesn't exist already (which it gets from the Windows log in) and adds "Copied_" to the front of the file.
Now I'm trying to get the VBA code to interact with the record. Presumably I need to tell the form button I'm using to launch the VBA code to pass the primary key of the record being displayed to VBA. Then, at the end of the VBA code I need to take that value and find the record again from VBA so I can update the MediaThumbnailLink in the original record.
Does this order of operations make sense? If so, how should I go about passing these values back and forth and writing the new link value?
Here's the VBA I'm using so far...
Code: Option Compare Database Public Sub GoCopyThumbnail() Dim fDialog As FileDialog Set fd = Application.FileDialog(msoFileDialogFilePicker) Dim varFile As Variant Dim LUser As String
I'm trying to open a folder based on a BIN nr. This folder could be in a main folder that has diferent subfolder. As there where differnt naming used to create the folderes, one of the things they have always is the BIN nr. It alwasy start with a unique number and maybe I could use it to scan the subfolders and open that one that the BIN nr is equal as in the field BIN.
Now we have serveral 1000th of folders and finding them takes time.
There is a manual process I'd like to automate. Instead of the user manually importing an external file into a table, I want a function to grab the most recent file in a particular directory. Is that possible?For example, I have a table called Input, and I want to append the file I just saved on my network, which in this case is G:Files2014TA_140928_011007.txt. The two ways to know which file to use is that the date is part of the filename (TA_ YYMMDD_ 999999. txt), and also the Date Modified attribute.
I am aware that if the user needs to work the files out of date order, he/she cannot use this code.
As you can see the picture naming system is standard and is based on the content in the type field. If one record of the Type field is say 12-6636 then the picture will be RC126636-01 (for Pic1) and RC126636-02.
Is there a way where the user say... can type C: and it will populate the picture file names in a combo box?
There are about 2000 records in the DB and I am just trying to find a way to keep a user from typing all that stuff.
:rolleyes: Could there be a way to do all 2000 records at once?...:rolleyes: Thanks.
I am new to Microsoft Access and have a little problem. I have searched the forum and nearly found the fix but I didnt quite understand what to do, so im creating a new thread.
I have a Access Database and have a client page that stores all the information about that client. We produce reports (scanned word/pdf) for each client and we store the report files in a client folder using the Client ID taken from Access.
My question is can I somehow produce a link from the Client Form in Access to the Client Folder or Files in explorer. I have seen the Hyperlink option but that is only availabe in Design View.
I am trying to set up a link to a file folder on the computer fore each individual, it is not going to the individual people, it is just going to the one person where I put the link to file.
I have a form with a subform.In the footer of the subform I have a combobox that get the file names of excel spreadsheets from a folder.I have a button (no code on it yet) that I want to press and import that spreadsheet into the table for the subform and associate it with the main form.
We have a server that we use to run a Microsoft Access application. This application creates folders, subfolders and files on the server.Users are in 4 different offices. Each office has at least 3 computers. Some users also work from home.
Users creates file through word, or scanning a document or by saving an email on their local pc.My problem is that users need to be able to save a file to a specific folder on server.
I'm trying to automate a process of selecting a set of file/s and move them in a folder. When I click on a button, it should open a current folder that is setup in the code.
Lets say that I have a folder C:documents est, and very time I click on the button, it should open the dialog box with that path so I can select the files from another folder, drag them there and they will be saved in that folder.
This will form part of wider automation that will send an email stating that those file/s where placed in that folder.
I have in the same form where the button is placed, 3 check boxes that needs to be passed to the email as well that one or all the files where placed in the folder.
I am currently using this path, but I moved my database folder into another folder so people won't mess with it. I still need to create files to the original directory. How can I make the FilePath still relative but up one folder from CurrentProject.path?
I'm trying to write a simple little database. At one point on a form, I'm trying to merge all the pdf files in a particular folder. (I'm using the pdftke.exe program and there will be multiple pdf files)
It all works perfectly if I call it as below, with the actual paths already hard coded. It combines all the pdf files and renames it to the "merged filename.pdf" correctly
Dim stAppName1 As String stAppName1 = "C:a folder namepdftk.exe C:another folder nameprints*.pdf cat output C:folder where merged file will bemerged filename.pdf" Call Shell(stAppName1, 1)
However, I'm trying to have it work with the middle portion (the folder where all the pdf files are) being created on the fly so to speak.
The middle portion/path I have stored from a previous form and it's stored in a table.
So I'm trying the below, but doesn't seem to work.
Dim stAppName1 As String Dim combine_files As String combine_files = (this pulls a path from a stored field on the open form) + "" + CStr("*.pdf")
stAppName1 = "C:a folder namepdftk.exe (combine_files) cat output C:folder where merged file will bemerged filename.pdf" Call Shell(stAppName1, 1)
With the code above, it doesn't seem to do anything.
I have a form which has a field called quote directory, this contains the path of the quote documents and sub folders, I also have a field called project directory.
When a quote is confirmed I have it all working so a new folder is created with specfic details like project number etc.What I want to do is move the folder from the quote directory and put it in the newly created folder in the project directory.
I added to my database a button to ouput the data to PDF. It works as it should. We do print out the letters in paper and put a copy in the folder from the client (connected with the ID nr). From time to time we need to attach a PDF document to the letter and combine it. My question is now if it is possible to have some code to the button that when it finish the output to PDF it will combine all the PDF files that are in the folder and put it in a second folder. After that, I need to put the combined PDF in another folder.