Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FoxPro and Excel-- Problem with macro
Message
De
03/05/1999 14:11:45
 
 
À
03/05/1999 14:04:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00214644
Message ID:
00214648
Vues:
16
Hi Mark ---

I copied the following from Excel VB Help:

If you use the Select method to select cells, be aware that Select works only on the active worksheet. If you run your Sub procedure from the module, the Select method will fail unless your procedure activates the worksheet before using the Select method on a range of cells. For example, the following procedure copies a row from Sheet1 to Sheet2 in the active workbook.

Sub CopyRow()
Worksheets("Sheet1").Rows(1).Copy
Worksheets("Sheet2").Select
Worksheets("Sheet2").Rows(1).Select
Worksheets("Sheet2").Paste
End Sub


This is off the top of my head, but shouldn't you specify ActiveSheet.Cells.Select?

>Hello guys ,
>
>Perhaps this is not the place to put this but, see if you can help me:
>
>I have this app that after the SQL select builds this table and then exports it to an EXCEL file, now I have this template that reads in this file and then formats it,(that's what is suppossed to do).
>The problem is that when the following code runs (VB macro in the Excel template)
>
>Workbooks.Open FileName:="C:\SMART\TEMP\TEST1.XLS"
> Cells.select <-- It dies here *****
> Selection.Columns.AutoFit
> Range("A1").Select
> Range("A2:M23").Select
> Selection.Copy
> ActiveWindow.WindowState = xlMinimized
> ActiveWindow.WindowState = xlMaximized
> Range("B12").Select
> ActiveSheet.Paste
> Application.CutCopyMode = False
> With Selection.Font
> .Name = "Arial"
> .Size = 8
> .Strikethrough = False
> .Superscript = False
> .Subscript = False
> .OutlineFont = False
> .Shadow = False
> .Underline = xlUnderlineStyleNone
> .ColorIndex = xlAutomatic
> End With
> ActiveWindow.ScrollColumn = 4
>
>It gives me a 1004 runtime error, 'select method of range failed'
>It ocurrs whenever you have empty info in the workbook or the object workbook does not exist.. but It does exists ..
>
>anybody ,, help!!
>
>Mark Oliva
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform