LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
pfa pfa is offline
external usenet poster
 
Posts: 14
Default Problem converting script from Excel 2003 to Ecel 2007

We have been running this script on 2003 for 2-3 years with no
problem...recently I upgraded my machine to 2007. When running the script,
the first error I get is that the file name is incorrect...so I noticed the
extension for 2007 is .xlam...added the "m" to the script...now it won't run
because of something else...
The error message I get now is "Runtime error 1004: method run of object
'_application' failed"...

Any suggestions will be greatly appreciated.

Sub Select_Sample()

Dim vNumber As Variant

'- Prompt for OK / Cancel
If MsgBox("This will erase the current sample on this worksheet",
vbOKCancel) = 2 Then
Exit Sub
End If

'- unprotect sheet to select
ActiveSheet.Unprotect
'- Get number of sample items to select
vNumber = Range("Number_of_Items").Value + 10

'- Clear output range for sample
Range("Sample_Range").ClearContents

'- call analysis toolpak to select sample
Application.Run "ATPVBAEN.XLAM!sample",
ActiveSheet.Range("$A$11:$A$65536") _
, ActiveSheet.Range("$K$11:$K$310"), "R", vNumber, False

'- copy conditional format to smaple selection
Range("Conditional_Format").Copy
Range("Sample_Range").PasteSpecial Paste:=xlPasteFormats,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'- Select cell & cancel copy
Range("J9").Select
Application.CutCopyMode = False
'- Reprotect sheet
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CONVERTING Excel 2003 Commands to 2007 Ra Excel Discussion (Misc queries) 5 May 25th 09 01:36 PM
Converting a 2007 Excel Spreadsheet w/ 2003 Greg Excel Discussion (Misc queries) 2 October 7th 08 10:59 PM
Excel 2003 vbs script problem Ralf Meuser Excel Programming 2 March 20th 08 11:54 AM
Trying to convert a excel 2003 to 2007, but it contain script. Feejo Excel Discussion (Misc queries) 3 January 2nd 08 01:19 PM
Trying to convert a excel 2003 to 2007, but it contain script. Feejo New Users to Excel 2 December 31st 07 07:08 PM


All times are GMT +1. The time now is 11:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"