Modules & VBA :: Universal Short File Path To Documents Folder?

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 Replies


ADVERTISEMENT

Modules & VBA :: Loop Through Folder - File Path Hyperlink

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

Universal Path For Exporting Table?

Aug 5, 2014

I've created a macro that will export one of my tables to a .csv. Everything is all fine and dandy, except that I need to find a way to have this command work on any computer. As of now, the command exports to C:UsersKodyDocuments, and can only do so because this path exists on my computer. But if I were to send this Access file to someone else to use, they would get an error stating that the specified path is not valid. Is it possible to create a general export directory which would work with any computer this is ran on?

View 5 Replies View Related

Modules & VBA :: Search For All Picture Files In Documents And Copy To A Folder On Desktop

Mar 28, 2014

I've been trying to search for all picture files in my documents and copy them to a folder on the desktop. I found this and it work great for searching however I'm having trouble getting the copy to work. [URL] ....

Code:
Dim colFiles As New Collection
RecursiveDir colFiles, "C:Photos", "*.jpg", True
Dim vFile As Variant
For Each vFile In colFiles
Debug.Print vFile
Next vFile

Code:

I replaced the debug.print vfile with my copy function. I've tried copyfile but it needs to specify the destination with the file name. I tried using the FSO filecopy method and can't get it to work (keep getting a compile error "Expected =") I feel the hard part is done and this part should be simple.

View 3 Replies View Related

Modules & VBA :: Adding Path Of Folder In Email

Jan 29, 2015

I have some code that takes data from my database and creates an email with it. It also creates a folder and a word document. In the email, I would also like to include the file path as a link instead of just the path that it puts there now. Is this possible to do?

Code:

Option Compare Database
Private Sub SendEmail_Click()
On Error GoTo Err_open_word_Click

Dim oApp As Object
Dim path As String

[Code] .....

View 1 Replies View Related

Get "folder Path" From "file Path"

Jul 29, 2005

After some help from one of the threads here I managed to install a Browse button in a form that inserts a file path to a text box. What I need is the folder path from that file path in another text box. For example if the file path is
C:Documents and SettingsmixupSketchesowl.jpg

I would like to get either
C:Documents and SettingsmixupSketches
Or,
C:Documents and SettingsmixupSketches
in my second text box.

I do not have much experience with Access; therefore please give a little detail on how to accomplish this.

Thanks.

View 9 Replies View Related

Modules & VBA :: Get Full File Path And File Name?

Oct 28, 2014

I'm having another one of those days but I'm getting a file path and file name from a dialogbox and forgotten when the VBA property is to return the full file path and file name.

This code works fine for return the filename only:

Code:

Private Sub TEST()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For I = 1 To f.SelectedItems.Count
MsgBox Filename(f.SelectedItems(I))
Next
End If
End Sub

Instead of using 'Filename' what else can I use to return what I need?

View 3 Replies View Related

Moving Documents Associated With One Customer From Main Document Folder To Another

Jan 28, 2015

I want to move documents associated with one customer from my main document folder to another. I've looked at some sample code but nothing seems to work

I want to run a query to get the document list

Run the code to move these files ( PDF Files )

and It's done...

View 14 Replies View Related

Modules & VBA :: Ask For File Path To Put In A String

Mar 5, 2014

I'm importing a txt file using the following code.

Now my question is, how can I make visual basic ask me to select a file to get the path and put it in a string.

And use this string in the DoCmd.TransfetText

Code:
DoCmd.TransferText acImportDelim, "IN-specification", "tblimport", "C:usersKimdesktop extfile.txt"

View 1 Replies View Related

Modules & VBA :: File Path Button

Aug 10, 2014

I am trying to code a button to select a file path.I get a compile error: User-defined type not defined on the following line;

Code:
Dim fldg As FileDialog

View 7 Replies View Related

Modules & VBA :: Get File Full Path

Jan 12, 2015

Im trying to programmatically (without any user intervention) retrieve the long path name for a given file. It seems to me this should be a rather easy thing to achieve using Access VBA. Ive tried using various FileSystemObject methods with no luck. Ive Googled many variants of VBA get full path without any meaningful hits. provide the first string as a parameter to some object and have it magically return the second string.

String 1: C:PROGRA~2COMMON~1MICROS~1VBAVBA7VBE7.DLL

Stint 2: C:Program Files (x86)Common Filesmicrosoft sharedVBAVBA7

View 7 Replies View Related

General :: Saving Program To Current User Documents Folder?

Aug 31, 2014

I have an access program and i want it to save a copy into a location... ive got it so it can save however - i want it to save to the current users documents folder (win 7)

What file path would i use?

View 5 Replies View Related

Modules & VBA :: Copy File From One Folder To Another

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

Modules & VBA :: Determine If File Exists In Sub Folder

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

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

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

Modules & VBA :: Path / File Access Error - Using Multipage

Jul 31, 2013

I've recently created a new Access 2010 Database which I'm developing an interface for in VBA. I've created a new Userform in the Visual Studio (this required me to add the Userform button). I'm finding that when I insert the Multipage object which I need to use on the form I can no longer run the Userform. When I attempt to run, I get the error 'Path/File Access Error' followed by 'Run time error 75 - Could not find the specified object'.

It's definitely linked to the Multipage which I've inserted from the toolbox (standard object) as the form runs fine when it is not there and with other objects (have tested all other toolbox items). There is currently no code in written in the project, no tables or queries set up in the database therefore nothing is running when the form loads.

I've successfully used Multipages in a number of other VBA interfaces both in Access and Excel so not sure why they are causing a problem here. I've also just created a userform in exactly the same way in a new Excel sheet and it runs fine with the multipage.

View 1 Replies View Related

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 2 Replies View Related

Modules & VBA :: Initial Folder Of Open File Dialog

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

Modules & VBA :: Create Subfolder And Copy File - Path Is Variable

Apr 18, 2014

I have a folder which holds 1000s of pictures organised in subfolders, for example:

D:~AI Database Print Scans2009family and
D:~AI Database Print Scans2009holiday

And so forth. In total at the moment 17 main subfolders, each of which hold another 2-3 subfolders.

I am putting together a database to bring pictures together with all sorts of details. I import the picture via hyperlink and complete the various fields. All that works fine but there are a lot of pictures! And it gets confusing to see which ones have already been entered into the database and which ones haven’t.

One solution for this is to copy the pictures that have been “completed” to another folder. I have found a way to do that:

Dim fs As Object
Dim oldPath As String, newPath As String
oldPath = Forms!frmPrintDetails.txtPath1
newPath = "D:~AI Database Print ScansCompleted_Entries"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath, newPath
Set fs = Nothing

Works fine, but the problem is that I loose the subfolder structure, it copies all pictures to the same main folder. I’d like to maintain the subfolder structure and add code to create the correct subfolders and next copy the picture. With the different paths I’m lost. I don’t know how to extract the correct path in code. I’d also like to either rename or remove the picture once I have completed entry of the details. The problem I have again is that I don’t know how to code for a changing path.

View 12 Replies View Related

Current Folder/path

Jun 11, 2006

Hi all

How can I change the output string in the command below to simply save the document to the same folder that the DB resides??

DoCmd.OutputTo acQuery, "qryAwardsExportWord", "RichTextFormat(*.rtf)", "C:dataawards.doc", True, "", 0

any help is appreciated

View 2 Replies View Related

Folder Path To Variable

Feb 28, 2007

I have a form set up and I am looking to:

Set up a txtbox that will house a variable (no worries)

I want a button that when clicked to open a "MS Windows window" that allows the user to navigate to a folder. When done I need that path to be placed in the textbox I set up (Or to a variable)

Does that make sense?

I thank you all for your help it is very appreciated.

Thanks Again

View 4 Replies View Related

Modules & VBA :: Run A Query And Export To Specific Folder As Excel File

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

Modules & VBA :: How To Save File From Attachment Field To External Folder

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

Modules & VBA :: Copying File To Specified Folder And Updating Records With New Location?

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

Modules & VBA :: Adding Button With Special Functionality - File Location In Database Path

May 28, 2014

In the access form I want to add a button with a special functionality.

After clicking "Select file" button special window should be open (or something else). It should give user a possibility of files locating (doc, pdf, rtf, txt ...).

After selecting the file and confirm the choice in the table "File_location" in database path to the file should be saved .

View 4 Replies View Related

Forms :: Relative Folder On Image Path

Jul 10, 2013

I am trying to link an images (.png) onto a form. I have a folder of all the images I want but I want the path to be relative. So that if I move the access file and the images folder to a new location, it will still work.

In the properties for the image, It works fine as C:UsersjohnDesktopimage1.png but what I am looking for is the ability to use "imagesimage1.png" as the file will always be in that relative folder to the db.

What is the correct syntax for this? putting image1.png in the same directory and just using image1.png works, but this won't be very tidy with 100+ images.

I have tried:

imagesimage1.png
imagesimage1.png
imagesimage1.png

With PictureType set as linked.

I know from searching it is possible through VBA by getting the root directory of the folder and appending the filename. Don't really want to go this root. I also don't particularly want to create a table to store the images or links.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved