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 May 29th, 2009, 09:53 AM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Workbooks.Open Filename error in a Macro

Hi there,

My macro is opening workbook:" "INFRACHEM_POLYMERS.xls" : When i try to run it, it hits me with an error saying that this workbook can't be found.

Code:
Columns("A:B").Delete Shift:=xlToLeft
    Columns("A:B").EntireColumn.AutoFit
    Columns("B:D").Delete Shift:=xlToLeft
    Columns("B:H").Delete Shift:=xlToLeft
    Range("A3").Activate
    Rows("1:3").Delete Shift:=xlUp
    Rows("2:2").Delete Shift:=xlUp
    Range("B2").Select
    ActiveCell.FormulaR1C1 = _
        "=OFFSET([INFRACHEM_POLYMERS.xls]Sheet1!R1C1:R56C1,1,0)"
    Range("B2").Select
    Selection.AutoFill Destination:=Range("B2:B59")
    Range("B2:B59").Select
    Columns("B:B").EntireColumn.AutoFit
    ActiveWindow.SmallScroll Down:=-3
    Workbooks.Open Filename:="INFRACHEM_POLYMERS.xls"
 
    End Sub
 
Old May 29th, 2009, 09:58 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you try using the fullname (Path and File Name)

Workbooks.Open Filename:="c:\INFRACHEM_POLYMERS.xls"

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ident Open Workbooks in Multiple Excel Instances DaveTheOgre Pro VB Databases 0 November 12th, 2008 03:33 AM
excel workbooks.open bug smiler_00 Pro VB 6 0 May 9th, 2007 05:24 AM
Macro to replace and updating sheets in workbooks vjs2445 Excel VBA 1 August 16th, 2004 02:51 AM
Display names of open workbooks in a MsgBox rmcc Excel VBA 1 November 11th, 2003 05:59 AM





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