Solved

Access 2007 MACRO: Transfer Spread Sheet

Posted on 2013-11-04
7
696 Views
Last Modified: 2013-11-05
I have a Transfer Spread Sheet macro that imports an excel file and I am wanting to create a file name path that will work for multiple users on my network and off my network.

So, here is what I have tried and it didnt work.

"\\%COMPUTERNAME%\Users\%username%\Documents\Import\file name.xls"
0
Comment
Question by:CMILLER
  • 4
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39622511
try doing this way..
in your macro add a single action (RunCode)
Action
RunCode


Function Name ImportXL()


now create a function in a regular VBA module

Function ImportXL()

dim strFile as string
strFile="\\%COMPUTERNAME%\Users\%username%\Documents\Import\file name.xls"

'complete this line for the TransferSpreadsheet command

docmd.transferspreadsheet acimport,8, "NameOfTable", strFile, true,"NameOfsheet!"

end function
0
 

Author Comment

by:CMILLER
ID: 39622763
It doesnt like this line even though I added the name of the TABLE and the Name of the Sheet

docmd.transferspreadsheet acimport,8, "NameOfTable", strFile, true,"NameOfsheet!"
0
 

Author Comment

by:CMILLER
ID: 39622791
It works if I use the actual computer name and username in the path
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39622942
change this line

strFile="\\%COMPUTERNAME%\Users\%username%\Documents\Import\file name.xls"

with

strFile=environ("userprofile") & "\Documents\Import\file name.xls"
0
 

Author Comment

by:CMILLER
ID: 39624620
That did it!!

I know that wasnt part of the question but how do I add a notification to the module that shows that the table updated?

Thanks
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39624698
add this line after the transferspreadsheet  command


msgbox "Table nameOftable was updated!"
end function
0
 

Author Comment

by:CMILLER
ID: 39624714
It worked, Thanks!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question