Use of CurrentProject.Path in export code

I have written some code, learned from generous people on this site, to export data to specific cells in an existing excel workbook The problem I now face is that the user will have to insert the path to the excel file-I would like to just instruct them to store the xls file in the same place that they stored the mdb file. I did get a form with some code that allows the user to select the file and find the path, but it doesn't work consistently in a2007 and not what I need anyway. The code below works.

Set oWB = oXL.Workbooks.Open("C:\Users\GG\Documents\TestingM isc\FileName.xls")

I can't seem to find a way substitute CurrentProject.Path & "\" & FileName.xls for the actual path-I assume that I am not using quotes properly, but have given up on trying combinations. Can someone tell me how to do it?

I am using A2007 in W7 64 bit computer

Sponsored Links:

Related Topics

Transferspreadsheet: cannot export to .xlsm
and I'm trying to export two tables to a .xlsm macro enabled workbook.

Here's the code:

Function Macro2() On Error GoTo Macro2_Err
DoCmd.TransferSpreadsheet acExport, 10, "Ass+Traf", CurrentProject.Path & "\queries.xlsm", True, "Sheet2"
DoCmd.TransferSpreadsheet acExport, 10, "ParqueSet2010 p/ Gessica", CurrentProject.Path & "\queries.xlsm", True, "Sheet3"
Macro2_Exit:
Exit Function Macro2_Err:
MsgBox Error$
Resume Macro2_Exit
End Function

When I replace xlsm for xlsx it works fine, but in the above case I get the following error:

"Cannot update. Database is read-only".

I checked the file properties, and the read-only box is unchecked.

Does anyone know why this happens?

I need to export to a xlsm because I want to build excel macros in the destination file ("queries


export to spreadsheet
I have code that I'm using for user to click a button and export data to excel. It works great. But I have the path to their c drive hard coded. Is there a way to code the path so each time they export the data; it changes the name of the spreadsheet? As it stands now; if they export data today and don't change the name of the spreadsheet before they export data again; itwill over write the existing spreadsheet.


Picture Management
I am trying to get away from multi-fields, since it's an Access exclusive. So what I was trying to do was make a button that checks for a directory currentproject.path/workorders/me.workorderid/pictures

This would probably work fine, but what I have realized is that currentproject.path is going to be a hidden folder, and I don't want the end user mucking around in this folder. Any other suggesstions


Display Linked table Path
One of my users would like the path to a linked table to be displayed at the top of a form. His reasons aren't the best, but---. I can display the mdb file path using [Application].[CurrentProject].[Path] but how do I do same for a specific linked object? I tried sticking the table name before path, but no go.


Troubles with currentproject.path
I have built up a Access app which imports a spreadsheet sitting within the same directory, runs a few queries and spits out a report at the end to the same directory. I keep the files in a folder on my desktop, but wanted to share the tool with a colleague.

In order to make sure the app would work no matter what directory they used to put the app and input files on thier computer, I employed the currentproject.path command:

CurrentProject.Path & "\input.xls"

It worked like a dream on my computer, and can move the app around from folder to folder without it falling over.

However, my colleague isn't so fortunate. When they run it, it goes off to look for the input files in their c:\temp directory. We've tried it with 2 other computers and get the same result. It works fine on mine (in any directory) but not on another PC


Split Database
This may be a silly question, but I am curious.
When a database is split, the back-end is placed in a centralized location and the front-end on the individual work stations. Say for example the current event of a form is running a code that is supposed to look at the current database's path using currentproject.path. I know that the code will be executed from the workstation where the front-end is open, but is it going to look at the path name of where the back-end is located? Because it is supposed to look in a folder that is in the same directory as the back-end


combobox take an activepath from column 2
I like to change an picture based on selection from an combobox
in Combobox I would like to see just the title (column1) but the imagine to take data from column 2 - where is stored the path to imagine:
this is the code from VBA:

Private Sub Combo3_Change()
'Me.Image0.Picture = CurrentProject.Path & "\" & Me.Combo3.Column(2)
Me.Image0.Picture = Me.Combo3.Column(2) End Sub Private Sub Form_Load()
'Me.Combo3.RowSource = "SELECT imagini.imagineID, imagini.titlu, imagini.cale_imagine FROM imagini ORDER BY [titlu]"
Me.Combo3.RowSource = "SELECT imagini.imagineID, imagini.titlu," & Application.CurrentProject.Path & "\" & "[cale_imagine] AS Expr1 FROM imagini ORDER BY [titlu]" End Sub

the error is on this line

Me.Combo3.RowSource = "SELECT imagini.imagineID, imagini.titlu," & Application.CurrentProject.Path & "\" & "[cale_imagine] AS Expr1 FROM imagini ORDER BY [titlu]"

syntax error missing operator


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


Change Import/Export directory via VBA
I would like to change the path of a stored import (Excel) via VBA rather than displaying the Manage Data Tasks window to my end-users. I'd like to display a popup allowing them to search for the correct folder, and then I would insert the selected string.

So far I found Application.CurrentProject.ImportExportSpecificati ons.Item but that is read-only and asking for the name of my stored import


autoexec--currentproject.istrusted
Would like a splash screen for it but never have set one up.

Also, before the form comes up I would like it to hide the ribbon and files on the left.

Lastly, I need it to check the current project to see if it is trusted. Unfortunately, All I found was currentproject.istrusted; which to me looks like vba code which isn't trusted. I triedputting it under condition but it puts brackets around it like it is fields.

Okay nevermind on the currentproject part I got that. just need the ribbon and files hiding and splash screen


How to change default export locaton for reports ?
When I export a Report to txt file, by default it is exported to 'User/My Documents' folder on C drive. For my application, I want the file to be exported to the same folder which contains the database. Is this possible ? I guess (and hope) it would be as simple as executing some code for relative path before the export; just don't know the


Storing images in a different location
I found a sample of a database that stores images in a sub folder located within the same directory as the mdb project file. The code is as follows:

'setup new file name and appropriate DB subfolder
relativePath = "\Persons_Images\"
dbPath = Application.CurrentProject.Path

I would like to modify the code above to store images somewhere else and not in the subfolder.


Delete a workbook if it exist From Access
I am looking to check to see if a workbook exists at the beginning of some code and if it does I want to delete it, but if it doesn't then continue with the code.

Currently I use the Kill statement, but if someone goes into the location of the workbook and they delete/rename it the next time I run it I get a debug on the Kill line.

Kill CurrentProject.Path & "\Peer Review Report.xls


Browse for Folder - absolute path
Ive just used Terry Krefts code to "browse for a folder path" and then store that folder path in a field in a table. This code works absolutely fine apart from one thing. When browsing to network shares, the function stores the relative path rather than the absolute path, so what is being stored is for example is the drive assigned letter on my PC ie M:\Folder, when really what I want is servername\share\folder


Compile error when exporting to Excel
Im a bit confused with a debug im getting. The code im running is very simple and works in my 2003 database (Im transferring to 2007).

Below is the code. The Path and FileName are both being read correctly. FOr some reason its giving a compile error variable not defined. Its highlighting the table I want to export (the table does exist and ive checked name/spelling). Does anyone know what could be wrong?

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, tbl_MyTable, Path & FileName


autoexec--currentproject.istrusted
Need a little help. trying to setup an autoexec.

Would like a splash screen for it but never have set one up.

Also, before the form comes up I would like it to hide the ribbon and files on the left.

Lastly, I need it to check the current project to see if it is trusted. Unfortunately, All I found was currentproject.istrusted; which to me looks like vba code which isnt trusted. I tried putting it under condition but it puts brackets around it like it is fields.

Can someone give me some ideas on how to set this up right?

Okay nevermind on the currentproject part I got that. just need the ribbon and files hiding and splash screen


Exporting Data from Microsoft Access with VBA Code
Access gives you two ways to export data, visually by going to File Export and then selecting an export format from a dialog box or by using VBA code. In this article we will be looking at how to export Access data using VBA code, since even a beginner can use the visual interface to export data. Using VBA code requires some ability to write code and also a basic understanding of the target applications object model.So why code? Because it offers you a wider choice of formats to export data to. It supports all the formats that is available in the dialog box as well as a whole host of others such as Microsoft Outlook contacts, appointments or a Word document .


How do I export multiple queries ?
I have codes for export that looks like this
[code]
and This above code export were only able to export one single query/table.

I would like to export more queries to one single excel when I am exporting. What should I add to my codes to make that happen?


Exporting a Access Report to an Excel File
I want to export my report to an excel file exactly the same as the inbuilt method, but with a fixed path to save it.is this possible?

Code currently using.

stDocName = "saveReportFormat"
DoCmd.OutputTo acReport, stDocName

is there a way I can do this, but not have the save window pop up and have a hard coded file path?

also I dont want to use.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, reportName, theFilePath, True

because this removes all formatting and only works on query's.unless there is a way to manipulate this code to save reports to file instead of queries?


How to export macros' commands as text?
I'm trying to devise a way to export code in an Access database as text such that I can use Csv meaningfully when I make changes. reports and modules, butalso the connection strings and SQL commands for queries, and the list of commands in all macros.

I've done all the VBA and queries, but I can't figure out how to get to macros' commands at all. I've examined all containers and documents in CurrentProject, all the Access objects in CurrentData, everything, and I can't find anything.

All I can do is save each macro as a module and then use the module-VBA system I have.