Modules & VBA :: 3 Separate Folders To Send PDF Files
Aug 12, 2015
the code below sends 3 reports to a folder that the vba creates if needed. I would like to change it so the 3 reports go to different folders and creates a folder with the customer name in each of the below folders if needed at present it looks table with one folder address is as I dont know how to make it look up the 3 different records in that table so I would like to just put the 3 folder address in the code
I'm using a function to find all files/folders in a specific directory, then copy each one to a specific destination folder. I'm going to use this on a weekly basis to backup files on a computer. I would like to use the vbarchive in GetAttr/SetAttr so I only need to copy these if they have changed since last backup.
Something like:
If GetAttr(strFile) And vbArchive = 32 then filecopy xxxx, xxxx else rs.movenext
As I understand it, a value of 32 indicates that the file has been modified since it was last backuped up (i.e. since the file attribute was "reset"). How do I "reset" the file attributes to clear the vbArchive?? I've read some google searches and the only thing I could find was the files were set to vbnormal however I'm concerned that this will erase program files that are vbReadOnly or VbHidden.
create/find code that will count the number of text files in a directory with one level of folders please see below:
Directory path is : B:
First and only level of sub folders:
there are 100 of these and they all end in ".fof"These .fof folders will always contain .txt files.I've tried using the following code, but it always returns No files found.
Code:
Dim lngFileCount As Long Dim StrFileName As String StrFileName = Dir$("B:*.txt") Do While Len(StrFileName) <> 0
I have a database which has several records with at least 5 documents needing to be attached to each record. Using attachments or OLE would cause considerable bloat, so I opted for hyperlink fields for all the document types necessary to save with each record. However, now I am faced with an issue. It is easy enough to write code to open the files by following the hyperlinks, as well as write code to send an email, but how would I go about combining the two? I need to write a code that will attach these documents to an email, as attachments and not as hyperlinks. I know with excel documents, I could follow the hyperlink and send the document by email through excel, but I also have images converted to pdf's that need to be sent as attachments.
I'm trying to get a complete list of folders within a given Folder but can only get it down to the level of the main folders sub folders but should a sub folder also contain folders it misses these.
My code below builds a list like:
c:fld1fld2fld3
This function is used to fill a combo box
Function ShowFolderList() As String Dim fs, F, f1, S, sf, All, AF, FC, sb, sb1, sbf, sbc Dim Lst As String Lst = "" Set fs = CreateObject("Scripting.FileSystemObject") Set F = fs.GetFolder(Me![FoldersRoot] & Me![StartInFolder]) Set sf = F.SubFolders For Each f1 In sf Lst = Lst & f1 & ";" Set sb = f1.SubFolders For Each sb1 In sb Lst = Lst & sb1 & ";" Next Next 'Now Remove The Last ; If Their If Right(Lst, Len(Lst)) = ";" Then ShowFolderList = Left(Lst, Len(Lst) - 1) Else ShowFolderList = Lst End If
Is there a good way to let Access be the database for collections of files and folders (on a Windows PC) that would organize projects and give information about the files. When I say information I mean description, progress(check in & check out duration of work, and timers), and location. I think this would work with organizing our projects and knowing what file is the current one we should be working on when we have many. A while ago I was working in FileMaker and noticed that one of there template options said "Collection of Files".
I've seen a lot of repeated questions from newbies about exporting to text, but so far I haven't come across a scenario like mine. Apologies if I've overlooked something.
I'm using Access 2003 and I have a database that contains a record for each article that appeared in a certain newspaper over the last 30 years (~70,000 records). Each record has a field for year, month, issue, page, title, and text. The text field contains multiple lines of HTML as well as the text of the article itself -- the program designed for viewing these articles calls on this field to create an html document that resembles the original newspaper page in the GUI.
What I would like to generate is a separate .TXT file for each article containing just the text of that article and a filename system that identifies each file by year, month, page, and possibly title (i.e., about 70,000 separate text files). I'm not sure if I want the title within the document or just in the filename, but I'm assuming that wouldn't be difficult to change.
In other words, I'm trying to work backwards, reconstructing the text files that the person who made the database probably has sitting on a disk somewhere (but I don't have access to).
I've read about using the TransferText method, setting up an export spec and looping it in VBA, etc., but the closest solution appears to be Microsoft's page on exporting records to separate HTML files (http://office.microsoft.com/en-us/access/HA010345961033.aspx), which mentions: "You can create a Microsoft Visual Basic for Applications (VBA) program that enumerates through the record set and uses the PRINT statement to output each record as a separate HTML file." After doing this I guess I would batch convert from HTML to TXT. Unfortunately I am new to Access and don't know VBA.
eg. file 1 => send to a@hotmail.com file 2 => send to b@hotmail.com file 3 => send to c@hotmail.com file 4 => send to d@hotmail.com file 5 => send to e@hotmail.com
send them at the same time, but different address. Can they do that? I think that it cannot be done this way, right. I think that it only send a file at a time, right. Please let me know. Thanks. Thanks.
I am trying to make some folders from a Query list to my C drive.I found this code for making folders. I have a button on a form with this code. It works with making a folder but only gives me the first item in the query out of many rows. It is missing the rest of the items.Also I would like it to be able to make Sub Folders too from this query.Here is the code I found.
Private Sub MakePreservationTagFolder_DblClick(Cancel As Integer) Dim strFolder As String strFolder = "C:UsersryanDocuments" & "Tag - " & DLookup("[Tag]", "Tags Qy")
I have the below code to create email and folders based on data from the database. For now, I'm able to create the main folder and add a word document inside. What could be changed on the code or added to add 2 sub folder named "Documents" and "Correspondence"
Greetings.
Code: Option Compare Database Private Sub SendEmail_Click() On Error GoTo Err_open_word_Click
I have over 500 folders that contain XML files in each folder. I need to go through each folder and append the data from the XML files into my database.
I have been looking into populating a tree-view with folders and files, and have found some great examples for doing this, How ever...I cannot seem to work out how to show files/pictures in a form based on the click event of the tree-view.
I have managed to do an onclick event for the files in the tree-view, but I cannot seem to get the onclick event for folders in a tree-view.
Here is an example which I am working on at the moment, but get the error Object variable Or with block variable not set.
Code: Private Sub tvw_Click() Dim tClient As String Dim tParent As Scripting.folder Dim fd As Scripting.folder Dim fNode As MSComctlLib.Node
I am trying to set up something to be able to take me to a folder that holds various forms for personnel. I have a query that generates the link for each person. I have tried to set it up as a hyperlink in ACCESS 2013 and it displays as one but doesn't act like one.
I want to be able to click the link and have it open up a personnel folder for that individual. I can't find a MACRO that I can create to do it. Example of my query is that it creates a link K:Main BreakdownSection BreakdownPersonnel FoldersName and the name is the variable part.
My next problem will be to have it create that folder when we have new personnel arriving.
I would also note that I have not worked with ACCESS in many years and much of what I was able to do with 2002 and 2003 doesn't work with the newer versions of ACCESS.
I have to write a code for my database,i have folder with files "pending Review" and a table with column "tblExcelLocation". when i run my database all the files from pending review folder goes to "tblExcelLocation" on a click of button.But,if the files already exists it should not insert those files and insert the rest.For this i tried to write a code but i think i m unable to do that .
Code: Loop through files in folder folderspec = "O:QA FilesQC ReportingPending Review" Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.files
I need to separate Users and admin on login so that the admin can go to admin form and users to specific form using vba access. Here is my login code
Private Sub cmdLogin_Click() 'Check to see if data is entered into the password box If IsNull(Me.cboUserName) Or Me.cboUserName = "" Then MsgBox "You must enter a Password.", vbOKOnly, "Required Data" Me.cboUserName.SetFocus
I have the requirement to write EACH record from a table to its own CSV file with name of the file being combination of 2 fields
So let's say I have Table1 with 3 columns (Field1, Field2, Field3) with following content :
Field1 Field2 Field3 AA 1 ABC AA 2 DEF AA 3 GHI
I should get 3 files with names AA1.CSV, AA2.CSV and AA3.CSV and each file contains its respective row from the table.
I tried to do it with DAO Recordset, but I do not find a way to write only the current record from recordset while looping.
See below the code I was using, but issue is that code does succesfull creates the 3 CSV files as per above example, but in each file it writes ALL 3 ROWS instead only the respective ROW.
Code: Dim db As DAO.Database Dim rs As DAO.Recordset Dim strSQL As String Dim strFilename As String
Trying to make this code work, don't know how to filter as it prints identical all reports.
Private Sub cmdExportPDF_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Dim MyPath As String MyPath = "C:Reports" If Len(Dir(MyPath, vbDirectory)) < 1 Then MkDir (MyPath)
I want to return a value from a separate query and have that show up in a field on my main form. The field name from the query is "Six Month Date" and the query name is "DT6Monthqry". I want to return the value displayed in the"Six Month Date" from the query, matching the CustomerID in the query result to the CustomerID that is being displayed on the main form. The CustomerID is a text field.This is the code I placed in the Control Source property for the field I want to be displayed on the main form:
I have the code for sending an email but I only want to send a single email when there are records in a query and only when the database is first opened.
I hadn't considered this in my design so what structural requirements would it require if any?
I currently have a code set up which sends an attachment from a drive on my computer to all the email addresses in a certain query. I would like to change the code so that I can add a button that will allow me to send an email with a specific attachment depending on their individual code in a table, e.g each person will receive a specific attachment. At the moment, the attachments are saved with the same file name as the person's specific code.The code I am currently using is:
Private Sub Command9_Click() Dim MyDb As DAO.Database Dim rsEmail As DAO.Recordset Dim qdf As DAO.QueryDef Dim prm As DAO.Parameter Dim strEmail As String Dim strMsg As String Dim oLook As Object
Since my old DB had hyperlink (web pages) either starting with http:// or not, and the users were complaining that they couldn't easily edit the field, I converted all the fields to text. Then I tried the following code on doubleclick:
Dim WebLink As String If Me.WebPage2 <> "http//" & "*" Then WebLink = "Http://" & Me.WebPage2 Else WebLink = Me.WebPage2 End If Debug.Print WebLink Application.FollowHyperlink WebLink, , True
The above works fine if there is no http:// but if there is one already in the text, then I get run time error 5 that it cannot locate the page. On checking what is happening, the code is adding http:// again even if it already there.
I use this to send email msgs through gmail, found it on the net somewhere, adapted a bit and it works.
Code: Private Function fSendGmail() As Boolean 'Returns True if No Errors are Generated On Error GoTo Err_ErrorHandler fSendGmail = True Const conStrPrefix As String = "http://schemas.microsoft.com/cdo/configuration/" Const conCdoSendUsingPort As Integer = 2
[Code] ....
Err_ErrorHandler: If Err.Number <> 0 Then fSendGmail = False etc, etc End Function 'fSendGmail
I'd like to send report attached to this as pdf or rtf. How should I go about it. I know how to create pdf and save it.(DoCmd.OutputTo acOutputReport, "My Report", acFormatPDF, strPath, True) But where do I attach that here? Is it necessary to save the file first?
I use a macro that attaches a document automatically to an e-mail address ready to send this report is governed by a query of which the criteria is " loss order number " this is in a pdf format of which I need if possible
The problem I have is the same pdf file keeps attaching itself to the e-mail no matter which loss order number I select. The reason I think is because the report is called NCR so it is not changing from the previous one. What I think can solve it but not sure and don't know how to do is get the " loss order number " within the report name.
If I just send the report to a file direct it does work as I am prompted for a file name
Can the loss order number get into the file name within a macro/vba