Topics Search

Use of CurrentProject.Path in export code

Use of CurrentProject.Path in export code
Views: 40
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:

Similar posts...


Transferspreadsheet: cannot export to .xlsm

Transferspreadsheet: cannot export to .xlsm Icon
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"
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

export to spreadsheet Icon
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

Picture Management Icon
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

Troubles with currentproject.path

Troubles with currentproject.path Icon
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

Display Linked table Path

Display Linked table Path Icon
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.

combobox take an activepath from column 2

combobox take an activepath from column 2 Icon
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

Change Import/Export directory via VBA

Change Import/Export directory via VBA Icon
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

Split Database : centralized location and the front-end on the individual work stations

Split Database :  centralized location and the front-end on the individual work stations Icon
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

Find path of file in different folder than the current Database

Find path of file in different folder than the current Database Icon
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

How to change default export locaton for reports ?

How to change default export locaton for reports ? Icon
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