ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error (https://www.excelbanter.com/excel-programming/297991-re-error.html)

steveb[_3_]

Error
 
RonS,

I put your code into an Excel 2002 workbook. Substituted the names of my
workbooks.
And it worked liked a champ.

The code didn't care if the 'filepath' workbook was already opened or not.
If it was already opened - the code just reopened it...

hth
steveb

"RonS" wrote in message
...
When running a macro to import data from another excel file I'm getting

the following error message.

"A document with the name "file_name.xls" is already open. You cannot

open two docs with the same name, even if the docs are in different folders.
To open the second doc, either close the cod that's open, or rename one of
the documents."

IN this case only one document is open, so I don't know why I'm getting

this message. Unless I have some excel options turned on that are causing
this issue. The macro is as follows:

Sub Import_Real_Estate_V6()
'
' Import_Real_Estate_V6 Macro
' Macro recorded 4/21/2004 by H241428
'

'05-May-03 KL: Obtain the directory location of the current file and

combine it with the import file

Dim filepath As Variant
filepath = Application.ThisWorkbook.Path & "\" &

"Real_Estate_Project_Plan_MilestonesV6.xls"

'05-May-03 KL End

'
Range("A1").Select
Workbooks.Open Filename:=filepath

Range("A1").Select
ActiveWindow.SmallScroll Down:=11
Range("O95").Select
ActiveWindow.LargeScroll Down:=-1
Range("A1").Select
ActiveWindow.LargeScroll Down:=1
Range("A1:O95").Select
Selection.Copy
Windows("Real_Estate_Practices_MilestoneScoreCardV 6.0.xls").Activate
ActiveWindow.WindowState = xlNormal
ActiveSheet.Paste
ActiveWindow.SmallScroll ToRight:=3
Range("A2").Select

End Sub





All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com