wwbwb
Well-known Member
- Joined
- Oct 20, 2003
- Messages
- 513
Greetings,
I have a workbook that pulls information from one workbook and places it in another for production auditing.
I have an XP machine running Office 2003 and the code works perfectly.
My boss's machine is an XP running Office 2007 and it works perfectly.
Two techs have XP machines running Office 2007 and both of them fail at the same line.
Workbooks(importbook).Close
I can not figure out why this is occuring. Ideas?
Here is the full code:
<code>
Sub Import()
'This code will pull the PR of the indiviual and save a copy of it for use in this workbook.
'Created Mar 2013, Will Bland
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Dim mypath As String
Dim importbook As String
'Warning to user about possible length of time calculations may take.
MsgBox "The import may take a couple minutes.", vbExclamation, "Import Warning"
'Gets and sets PR name and location
importbook = Range("B2")
mypath = Range("l1").Value & Range("B2") & ".xls"
If Len(Dir(mypath)) = 0 Then GoTo error01:
'Preps worksheet for use
Workbooks("Roll Up.xls").Sheets("Previous").Range("A1:e65000").ClearContents
Workbooks.Open mypath
'Copies relevant data and copies to this workbook
Sheets("Previous").Select
Range("A1:E65000").Select
Selection.Copy
Workbooks("Roll Up.xls").Activate
Sheets("Previous").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Dim rng As Range
Dim rng2 As Range
Set rng = Range("d1:d" & Range("d" & Rows.Count).End(xlUp).Row)
For Each rng2 In rng
If rng2 = "x" Then
rng2.Offset(, -1).Value = "x"
End If
If rng2 = "X" Then
rng2.Offset(, -1).Value = "x"
End If
Next rng2
Workbooks(importbook).Close
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Sheets("Report").Select
Range("A1").Select
'Lets user know import and calculations are complete.
MsgBox "The import has finished.", vbInformation, "Import Complete"
Exit Sub
error01:
MsgBox "The PR you are trying to import from is missing.", vbCritical, "PR Missing"
Range("B2").Select
End Sub
</code>
I have a workbook that pulls information from one workbook and places it in another for production auditing.
I have an XP machine running Office 2003 and the code works perfectly.
My boss's machine is an XP running Office 2007 and it works perfectly.
Two techs have XP machines running Office 2007 and both of them fail at the same line.
Workbooks(importbook).Close
I can not figure out why this is occuring. Ideas?
Here is the full code:
<code>
Sub Import()
'This code will pull the PR of the indiviual and save a copy of it for use in this workbook.
'Created Mar 2013, Will Bland
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Dim mypath As String
Dim importbook As String
'Warning to user about possible length of time calculations may take.
MsgBox "The import may take a couple minutes.", vbExclamation, "Import Warning"
'Gets and sets PR name and location
importbook = Range("B2")
mypath = Range("l1").Value & Range("B2") & ".xls"
If Len(Dir(mypath)) = 0 Then GoTo error01:
'Preps worksheet for use
Workbooks("Roll Up.xls").Sheets("Previous").Range("A1:e65000").ClearContents
Workbooks.Open mypath
'Copies relevant data and copies to this workbook
Sheets("Previous").Select
Range("A1:E65000").Select
Selection.Copy
Workbooks("Roll Up.xls").Activate
Sheets("Previous").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Dim rng As Range
Dim rng2 As Range
Set rng = Range("d1:d" & Range("d" & Rows.Count).End(xlUp).Row)
For Each rng2 In rng
If rng2 = "x" Then
rng2.Offset(, -1).Value = "x"
End If
If rng2 = "X" Then
rng2.Offset(, -1).Value = "x"
End If
Next rng2
Workbooks(importbook).Close
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Sheets("Report").Select
Range("A1").Select
'Lets user know import and calculations are complete.
MsgBox "The import has finished.", vbInformation, "Import Complete"
Exit Sub
error01:
MsgBox "The PR you are trying to import from is missing.", vbCritical, "PR Missing"
Range("B2").Select
End Sub
</code>