Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2011, 05:06 PM
Registered User
 
Join Date: Apr 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA code in Off 2000 doesn't work in Off 2003-

I want to transfer data (a worksheet)from Excel program A to Excel program B the following code to open the second program works in Off 2000 but does not in 2003-

One problem seems to be that Off 2000 does not recognize "Environ" but that is not the only problem the construct of the ChDir statement seems wrong.
Any help appreciated.
Thanks

(Office 2000 VBA code)
NameOwner = Environ("UserName")
ChDir "C:\Documents and Settings\" & NameOwner & "\Desktop"
Workbooks.Open Filename:="C:\Documents and Settings\" & NameOwner & "\Desktop\FileA\Bookl.xls"
 
Old April 24th, 2011, 05:08 PM
Registered User
 
Join Date: Apr 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Off 2000 does not recognize "Environ" that should read Off 2003-
 
Old April 24th, 2011, 08:52 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 171
Thanks: 0
Thanked 14 Times in 14 Posts
Default

As a simple workaround, if the workbook is in their "My Documents" folder, you could just use
Code:
ThisWorkbook.Path
and then do a little string manipulation. I don't have Office 2000 any longer, so can't check what the issue is, but you may have to do an API call if you can't use ThisWorkbook.Path: http://windowssecrets.com/forums/sho...cel-2000-sr-1)
Hope that solves it for you.
 
Old April 25th, 2011, 09:06 AM
Registered User
 
Join Date: Apr 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks I will try that.





Similar Threads
Thread Thread Starter Forum Replies Last Post
TRIM, ISTEXT function won't work in Excel VBA code munzer1 Excel VBA 1 May 29th, 2007 09:35 AM
Dowloaded code (VB.NET 2003) does not work kadesskade VB.NET 2002/2003 Basics 2 July 10th, 2006 12:49 AM
Word 2000 VBA code John Stark Excel VBA 0 March 1st, 2006 06:02 AM
Half the code in Access 2000 VBA doesn't work disruptivehair BOOK: Beginning Access VBA 0 December 26th, 2005 02:21 PM
ACCESS 2000 VBA CODE TO "SAVE AS" EXCEL ckentebe Access 0 May 25th, 2004 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.