Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with code on other PCs

Status
Not open for further replies.

tweek312

Technical User
Dec 18, 2004
148
US
I wrote the code below to work as a button in an excel spreadsheet. For some reason when using this code on another persons computer the code will crash on the "paste" and end abrubtly. Please note: This code does work on my computer but not on anyone elses in my company.

Not sure if this could be the problem but I am running Office 2003 SP2 on WinXp SP2. Whereas most of my colleagues are using Office 2003 SP1 on WinXp SP1.

Thankies!
tW33k
 
LOL... Forgot to attach the code.

Code:
Sub prep_everpt()

'makes sure user wants to prep report
Dim ReturnValue As Integer
   ReturnValue = MsgBox("Are you sure you want to compile the report?", vbQuestion + vbOKCancel, "Compile Report")
   Select Case ReturnValue
   Case vbOK
      
   Case vbCancel
      Exit Sub
   End Select

Application.ScreenUpdating = False

'convert to values
Sheets("live_status").Copy
 Application.DisplayAlerts = False
    Range("A1:N64").Select
    Selection.Copy
    Range("A1:E1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False


'delete chart 6
ActiveSheet.ChartObjects("Chart 6").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.Delete

'delete chart 7
ActiveSheet.ChartObjects("Chart 7").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.Delete

'delete chart 11
ActiveSheet.ChartObjects("Chart 11").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.Delete

'delete buttons
ActiveSheet.Shapes("Button 8").Select
Selection.Delete
ActiveSheet.Shapes("Button 12").Select
Selection.Delete
ActiveSheet.Shapes("Button 13").Select
Selection.Delete
ActiveSheet.Shapes("Button 39").Select
Selection.Delete

Application.ScreenUpdating = True

'breaks all links
Call break_links

'to clear the selection
Range("A1").Select

'saves file as name + date
ActiveWorkbook.SaveAs ("Q:\live_updates\cs_email\ES_Report_" & Format(Date, "mm.dd.yy") & ".xls")

Dim ReturnValue2 As Integer
    ReturnValue2 = MsgBox("I will now open an instance of Outlook...", vbExclamation + vbOKOnly)
    
    Select Case ReturnValue2
    Case vbOK
    
    VBA.Shell ("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE")
End Select

'prepares send dialog
Application.Dialogs(xlDialogSendMail).Show arg1:="Test Dist List", arg2:="Process Support Evening Status Report"
ActiveWorkbook.Close

End Sub

Code:
Private Function break_links()
aLinks = ActiveWorkbook.LinkSources(xlLinkTypeExcelLinks)
If Not IsEmpty(aLinks) Then
For i = UBound(aLinks) To 1 Step -1
  ActiveWorkbook.BreakLink aLinks(i), xlLinkTypeExcelLinks
Next i
End If
End Function
 
You want to paste a 14 columns wide selection into 5 columns only ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That seems Oh Too Obvious. I guess the real question now is why it would work on one computer and not another. I would think that an error like that would not work on any version of Excel. Peculiar.. is it not?

Thanks,
tW33k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top