[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Access 2007 MACRO: Transfer Spread Sheet

Posted on 2013-11-04
7
Medium Priority
?
761 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 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