Modules & VBA :: Creating Opening And Put Excel File In Folder
Oct 21, 2013
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
[code]....
View Replies
ADVERTISEMENT
Oct 13, 2014
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 tried several combinations of either:
- docmd.runsavedimportexport "Query"
- docmd.outputTo acquery etc ...
View 3 Replies
View Related
Aug 14, 2015
Question: Is it possible, using VBA, to determine the actual Excel file type without opening the file?
I receive data files from other departments. Seems like every time someone changes their download structure, I end up with file types that do not match the download extension (example: xlm file with a xls extension). The files can't even be opened because of this. I think I can fix it if I could figure out how to determine what the file type really is.
I'm using Office 2010.
View 3 Replies
View Related
Sep 21, 2014
I am trying to program a button on my ms access form to open up an excel file.. So far the simplest code ive found online was from URL....
<code>
Private Sub Command57_Click()
Dim xlTmp As Excel.Application
Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open "C:Excel1.xls"
xlTmp.Visible = True
[code]...
However the code doesn't work, any way to open a file from within access?
View 1 Replies
View Related
May 13, 2014
I have the following code, which works the way I want it to when I click the button the first time. However, if I close out the excel and click the button again, it errors at the line "ActiveWorkbook.Worksheets("Ref").UnProtect", with the message "Run-time error '91', Object variable or With block variable not set". I can not figure this out, why in the world does it work the first time, but not the second???
Private Sub cmdReport_Click()
Dim path As String
Dim XL As Object
Dim oBook As Excel.Workbook
Dim pic As Excel.Shape
Set XL = CreateObject("Excel.Application")
[code]...
View 5 Replies
View Related
Jan 27, 2015
Is there a way to create some sort of an EXE or BATCH file in any Windows Explorer folder, that executes me a specific Excel Macro?
My problem is that I got several files split up by Departments, updated every day.
So far I have to open each file and update the format.
It would make my life much more easier if I could just run a file that opens each file and applies a format to them.
View 1 Replies
View Related
May 23, 2014
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.
View 11 Replies
View Related
Aug 26, 2005
I created an Excel file using:
DoCmd.OutputTo acOutputQuery, _
"Compile_Query", acFormatXLS, _
"G:ServiceCompanySanDiegoWarehouseLCDLine_Summa riesDaily" _
& DateMonth & DateDay & DateYear & ".XLS", False
However, after creating this excel file, i want it to automatically open.
Is there any way to do this in 97?
View 1 Replies
View Related
Feb 28, 2014
I need to create a function that I can launch using a macro that will copy an excel file from one folder to another in the file system.
View 4 Replies
View Related
Mar 9, 2005
Hi guys, this might be a quickie, I did a quick search but couldn't find anything :/
Basically my database creates a table which some people would rather analyse within excel because they're not comfortable with access. I can get the table exporting to an xls file no problem, howeevr what I would like is for the database to export the file and open the file in excel at the same time so the user doesn't need to open up excel and find the file etc...
Any ideas??
View 2 Replies
View Related
Dec 15, 2014
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
View 5 Replies
View Related
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
Code:
objShellApp.Namespace(.GetAbsolutePathName(strFile)).Items
...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.
View 14 Replies
View Related
Apr 27, 2015
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)
[Code] .....
View 11 Replies
View Related
Nov 19, 2013
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")
[Code] .....
View 4 Replies
View Related
Nov 20, 2006
I am stuck with a problem where I need to create a new table from an excel file. In detail my problem is;
The excel file contains an order from a customer, like below,
BOM Component Qty
123 abc 2
123 def 2
234 ert 1
234 qwe 1
234 uio 1
I need to create a table from this data like;
Qty Partno
1 123
4 abc
4 def
1 234
2 ert
2 qwe
2 uio
NB! In reality the components are numbers not letters.
The qty for BOM is always 1 and the component 2xqty.
It is important that the BOM number is listed first and thereafter its components.
So I need to somehow associate the BOM number with its components and list them together as a group.
I just cannot figure out how to do this.
ANy help is greatly appreciated.
View 1 Replies
View Related
May 27, 2014
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
[Code] .....
View 9 Replies
View Related
Sep 5, 2014
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.
View 1 Replies
View Related
Jan 28, 2015
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
[Code] ....
View 2 Replies
View Related
Dec 22, 2006
Hi All,
I have three excel files (ActualHires.xls, ActualPromotions.xls and
ActualSeparation.xls). These are password protected files (with the
same password). They are linked to an access database and whenever the
files are opened, one must supply the password and click the 'Enable
automatic refresh button.' What I was wondering was if this could be
done in access with a command button. I have pasted some code below
that I found but now I'm getting an error.
This is the code:
Dim BookNames As Variant
Dim B As Long
BookNames = Array("O:ExcelFilesActualHires.xls",
"O:ExcelFilesActualPromotions.xls",
"O:ExcelFilesActualSeparations.xls")
For B = LBound(BookNames) To UBound(BookNames)
WorkBooks.Open FileName:=BookNames(B), _
UpdateLinks:=3, Password:="*******"
WorkBooks(B).Close SaveChanges:=False
Next B
But when I click the button, I get this error:
Run-time error '9' Subscript out of range.
and this line is highlighted:
WorkBooks(B).Close SaveChanges:=False
Any help would be greatly appreciated.
Thanks.
View 1 Replies
View Related
May 22, 2013
I am trying to create an access table linked to an excel file.
The excel file has 256,000 kb, 15 columns, 6,400 rows.
When I go to CREATE, DESIGN VIEW in access and try to create the new linked access table i get this message -
"MICROSOFT ACCESS HAS ENCOUNTERED A PROBLEM AND NEEDS TO CLOSE". I click on Ok and then it says "REPAIR MY OPEN DATABASE AND RESTART MS ACCESS".
I click on OK and then save the back up file. The file disappears. I start over again and the same process starts again and again...
View 14 Replies
View Related
Jul 22, 2015
I've got a table with field define as hyperlink which stores link to a external pdf.
Then i create a form including this field and add a unbound field which has got intermet browser format (as a type).
What code I have to put in onclick event in a hyperlink property sheet to open PDF inside the form?
View 1 Replies
View Related
Sep 4, 2013
I have a query, which looks like that:
ID Year SAP Geris
1 2008 20,00 € 5,00 €
1 2009 40,00 € 4,00 €
1 2010 60,00 € 6,00 €
2 2007 80,00 € 4,00 €
2 2008 100,00 € 8,00 €
2 2009 100,00 € 4,00 €
3 2008 1.000,00 € 1,00 €
3 2009 100,00 € 8,00 €
3 2010 2,00 € 9,00 €
4 2008 9,00 € 10,00€
So each combination has an ID. It's called the SuWID. I want to Transfer the data to a fixed Excel sheet. I wrote the following code
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object ' Excel.Worksheet
Dim rst As DAO.Recordset
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
[Code] ....
The only Thing what i still want to have is that, before it opens the Excel form, which works already perfectly well, that a msgbox will Show up and ask me, which SuWID do you want to see in the Excel sheet.
View 14 Replies
View Related
Mar 16, 2015
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.
View 3 Replies
View Related
May 27, 2015
I want to open files from a networklocation from VBA, only normal users don't have access to that location (and should preferably not get it).
I instead of using shell("explorer.exe filepath") to open files using windows standard app for the file, which needs userpermissions to the path the file is located, for the currently logged in user.
I'm trying to use CPAU in combination with Shell, because using CPAU you can pass a user/password that has permission to open a process
The only problem is that the filepaths have spaces in them and that is Always a bit of a tricky thing to tackle.
So, for example, this works:
shell("N:GuidelineOntwCPAU -u DomainUser -p password -LWOP -ex " &
Chr(34) & "C:windowsExplorer.exe c: emp est.pdf")
But I cannot get it to work with a file that is on a path with a space in it (or with a space in the name), like
Code : N:EngineeringJB-MATBBBB-004_Panel PinBB-004_Panel Pin.pdf
I'm trying all kinds of thinks:
- adding chr(34) at certain places
- using """
- the above in different versions
But to this point without result.
Trying to figure out the plain cmdline:
Code:
N:GuidelineOntw10_Ontwcpau -u Domain/User -p Password -ex "c:windowsExplorer.exe "c: emp est.pdf""
Doesn't work:
Code:
N:GuidelineOntw10_Ontwcpau -u Domain/User -p Password -ex "c:windowsExplorer.exe "c: emp est 1.pdf""
(difference in filename with a space in it)
The last command start explorer, but doesn't open the file (just as the first line I posted, it opens Explorer, but not the file. Must be something with the way I pass the filename?)
Code : explorer.exe "C: emp est 1.pdf"
Also works in commandline...
View 4 Replies
View Related
Feb 15, 2015
When creating an incoming inspection database, I want to set it up so when I am in a form to add data, I want to have a command button where I can pull up the associated CAD drawing based on part number and drawing number. I would like to enter the directory location into a table so I could change it if I need to.
So basically I want to go something like this:
.tblDirctoryLocation
txtDirectory
.tblProduct
txtProductName
txtProductNumber
txtProductCADNo
These tables would not be related to one another as there will only be one record for the directory location and multiple records for products.
Somehow I want the db to assemble file location like this:
“EQuality_DirectoryIncoming” & “ProductNumber_” & “CADDrawing” & “.pdf”
End result: EQuality_DirectoryIncomingProductNumber_CADDraw ing.pdf
Is there any way this could be done?
View 1 Replies
View Related
May 13, 2014
I would need removing the lines from an .xls file(stored in shared folder) and saving the same. I used the below code and not successful in removing and saving the file stored in the shared area..When I execute the code, Cursor hangs at this line
Set objWB = objXL.Workbooks.Open(filename)
Code:
Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.Workbooks.Open(filename)
Set objWS = objWB.Worksheets("Sheet1")
objWS.Rows("1:6").Delete
[code]...
View 3 Replies
View Related