Excel VBA Kopierern durch .Workbooks . .. oder .Windows .. OOP Methode

DocAElstein

Banned user
Joined
May 24, 2014
Messages
1,336
'
'‚. Hello Leute. … ---o00o---`(_)`---o00o---
'‚.
'‚. Ich bin eine Neuling zu Excel VBA und versuche die Theorie etwas besser zu verstehe.
'‚.
'‚. Ich wollte an einfach Direkt Methode um die Werte aus einer Cell in eine
'‚ Excel Mappe
(Mappe2) zu kopieren in eine andere Excel Mappe (Mappe 1).
'‚ Ich wollte die Code selber schreiben durch eine verstand von VBA,
'‚ statt einfach beim benutzen Makro aufzeichnen
'‚ .
'‚. Das ist (soll) ja etwas einfach und ich hab es geschafft.
'‚ Allerdings ich verstehe nicht warum manche Methode die ich probiere nicht funktioniere.
'‚ Es liegt wahrscheinlisch in die Objekt/Klasse/Orientiren Konzept das ich noch nicht ganz verstehe.
'‚ . (Oder ist es so dass man kann nur eine Value geben oder nehmen von eine Mappe
'‚ das nicht aktivieret ist, mit die
Windows .Aktive cell Methode? -
'‚ Man kann also nicht angreifen an cells wenn eine Mappe nicht Aktivieret ist?)
'.
'. Eventuelle kann eine Profi mir Hilfen:-
'.
''. Die folgenden 4 Codes sind eine versuche an an einfach direkt Methode.
''. Allerdings nur die vierte scheint bei mir zu funktionieren!
''.
''‚…………… ……….---o00o---`(_)`---o00o---
''.------ 1'.

Sub WorkbooksCellsMethodDirekt()
Excel.Application.Workbooks("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
= Excel.Application.Workbooks("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value
End Sub



'.
'. -------------- 2
'.

Sub WorkbooksActiveCellMethodDirekt()
Excel.Application.Workbooks("Mappe1.xlsm").Application.ActiveCell.Range("a1").Value _
= Excel.Application.Workbooks("Mappe2.xlsm").Application.ActiveCell.Range("a1").Value
End Sub


'.
'. ------------------------ 3
'.

Sub WindowsCellsMethodDirekt()
Excel.Application.Windows("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
= Excel.Application.Windows("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value
End Sub


'.
'. --------------------------------------- 4
'.

Sub WindowsActiveCellMethodDirekt()
Excel.Application.Windows("Mappe1.xlsm").Activate
Excel.Application.Windows("Mappe1.xlsm").ActiveCell.Range("a1").Value _
= Excel.Application.Windows("Mappe2.xlsm").ActiveCell.Range("a1").Value
End Sub
'.
'. ----------------------------------------
'.
'. Es sieht also als ob nur die
Windows "Objekt" hat eine extra Activecell
'. statt nur Application.Activecell zu verfugen. Irgendwie macht das die unterscheid!!!.
'.
' (Bzw.
Workbooks hat .Application.Cells und .Application.ActiveCell.
'. Windows hat auch dieses .Application.Cells und .Application.ActiveCell,
'. allerdings Windows hat an extra .ActiveCell das Workbooks nicht hat!?!?)
'.
'. Kann jemand erkläre das mir!!?!
'.
'Danke, Alan Elston.
'. Hof,Bayern den 22.05.2014
'. Email DocAElstein@t-online.de
'.............
'.
'. P.s. Eine mehr komplizieret Methode mit eine zwischen Lager funktionieret bei
'. jede 4 Methode. Bzw. Die folgenden 4 Codes funktionieren alles Einbahn frei!!
'.
'.----------- ---o00o---`(_)`---o00o---


Sub WorkbooksCellsMethodMitZwischenLager()
Dim ZwischenLager As Double

Excel.Application.Workbooks("Mappe2.xlsm").Activate

Let ZwischenLager _
= Excel.Application.Workbooks("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value

Excel.Application.Workbooks("Mappe1.xlsm").Activate

Excel.Application.Workbooks("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
= ZwischenLager
End Sub
'.
'. -------------------------------------------
'.


Sub WorkbooksActiveCellMethodMitZwischenLager()
Dim ZwischenLager As Double

Excel.Application.Workbooks("Mappe2.xlsm").Activate

Let ZwischenLager _
= Excel.Application.Workbooks("Mappe2.xlsm").Application.ActiveCell.Range("a1").Value

Excel.Application.Workbooks("Mappe1.xlsm").Activate

Excel.Application.Workbooks("Mappe1.xlsm").Application.ActiveCell.Range("a1").Value _
= ZwischenLager
End Sub
'.
'. ----------------------------------------
'.

Sub WindowsCellsMethodMitZwischenLager()
Dim ZwischenLager As Double

Excel.Application.Windows("Mappe2.xlsm").Activate

Let ZwischenLager _
= Excel.Application.Windows("Mappe2.xlsm").Application.Cells(1, 2).Range("a1").Value

Excel.Application.Windows("Mappe1.xlsm").Activate

Excel.Application.Windows("Mappe1.xlsm").Application.Cells(1, 1).Range("a1").Value _
= ZwischenLager
End Sub
'.
'. -------------------------------------------
'.

Sub WindowsActiveCellMethodMitZwischenLager()
Dim ZwischenLager As Double

Excel.Application.Windows("Mappe2.xlsm").Activate

Let ZwischenLager _
= Excel.Application.Windows("Mappe2.xlsm").Application.ActiveCell.Range("a1").Value

Excel.Application.Windows("Mappe1.xlsm").Activate

Excel.Application.Windows("Mappe1.xlsm").Application.ActiveCell.Range("a1").Value _
= ZwischenLager
End Sub
'. -------------------------------------------------
'
 
<font face="Courier New", Monospace><SPAN style="color:#00007F">Sub</SPAN> WindowObjectDemonstration()<br><br>    <SPAN style="color:#00007F">Dim</SPAN> strMsg  <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>        wbNew   <SPAN style="color:#00007F">As</SPAN> Excel.Workbook, _<br>        i%<br><br>    <SPAN style="color:#00007F">With</SPAN> Application.ThisWorkbook<br>        <SPAN style="color:#00007F">Do</SPAN> <SPAN style="color:#00007F">Until</SPAN> .Windows.Count = 1<br>            .Windows(.Windows.Count).Close<br>        <SPAN style="color:#00007F">Loop</SPAN><br>        .Windows(1).Visible = <SPAN style="color:#00007F">False</SPAN><br>        <SPAN style="color:#00007F">Let</SPAN> strMsg = "This workbook has " & .Windows.Count & " even though it is not visible."<br>        MsgBox strMsg, vbInformation<br>        <SPAN style="color:#00007F">With</SPAN> .Windows(1)<br>            .Visible = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#007F00">'            .WindowState = xlMinimized</SPAN><br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <br>    <SPAN style="color:#00007F">Set</SPAN> wbNew = Workbooks.Add(XlWBATemplate.xlWBATWorksheet)<br>    <SPAN style="color:#00007F">With</SPAN> wbNew<br>        <SPAN style="color:#00007F">With</SPAN> .Worksheets<br>            .Add After:=.Item(.Count)<br>            .Add After:=.Item(.Count)<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        .NewWindow<br>        .NewWindow<br>        .NewWindow<br>        <SPAN style="color:#007F00">'// this code works sometimes and other times</SPAN><br>        <SPAN style="color:#007F00">'// it does not.  Unsure why the inconsistency.</SPAN><br>        .Windows.Arrange xlArrangeStyleTiled<br>        <br>        <SPAN style="color:#00007F">Let</SPAN> strMsg = "The new workbook has " & .Windows.Count & " and all are visible."<br>        MsgBox strMsg, vbInformation<br>        <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> 3<br>            <SPAN style="color:#00007F">With</SPAN> .Windows(.Name & ":" & i)<br>                .Activate<br>                .Parent.Worksheets(i).Activate<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">With</SPAN> ActiveSheet<br>                <SPAN style="color:#00007F">With</SPAN> .Range(.Cells(1, 1), .Cells(i * 3, i * 3))<br>                    <SPAN style="color:#00007F">With</SPAN> .Interior<br>                        .ThemeColor = xlThemeColorAccent1 + (i - 1)<br>                        .Pattern = xlSolid<br>                        .PatternColorIndex = xlAutomatic<br>                        .TintAndShade = 0.8<br>                        .PatternTintAndShade = 0<br>                    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>                    .Select<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>                <SPAN style="color:#00007F">With</SPAN> .Cells(i, i)<br>                    .Interior.TintAndShade = 0.4<br>                    .Activate<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> i<br>        <SPAN style="color:#00007F">With</SPAN> .Windows(.Name & ":" & 4)<br>            .Activate<br>            .Parent.Worksheets(1).Activate<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">With</SPAN> ActiveSheet<br>            <SPAN style="color:#00007F">With</SPAN> .Range("D4:G8")<br>                <SPAN style="color:#00007F">With</SPAN> .Interior<br>                    .ThemeColor = xlThemeColorAccent4<br>                    .Pattern = xlSolid<br>                    .PatternColorIndex = xlAutomatic<br>                    .TintAndShade = 0.8<br>                    .PatternTintAndShade = 0<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>                .Select<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">With</SPAN> .Cells(5, 5)<br>                .Interior.TintAndShade = 0.4<br>                .Activate<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <br>        <SPAN style="color:#00007F">Let</SPAN> strMsg = ""<br>        <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> .Windows.Count<br>            <SPAN style="color:#00007F">With</SPAN> .Windows(i)<br>            <SPAN style="color:#00007F">Let</SPAN> strMsg = strMsg & "Window #:" & i & vbCr _<br>                       & "Window Caption: " & .Caption & vbCr _<br>                       & "Active Cell: " & .ActiveCell.Address(0, 0) & vbCr _<br>                       & "Selected Range: " & .RangeSelection.Address(0, 0)<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> i <> .Windows.Count <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#00007F">Let</SPAN> strMsg = strMsg & vbCr & <SPAN style="color:#00007F">String</SPAN>(10, "—") & vbCr<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> i<br>        .Windows(.Name & ":1").Activate<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br>    MsgBox strMsg, vbInformation<br>    <br>    <SPAN style="color:#00007F">If</SPAN> vbYes = MsgBox("Close new workbook", vbQuestion + vbYesNo) <SPAN style="color:#00007F">Then</SPAN><br>        wbNew.Close <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <br>        <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br></FONT>
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Note that if all I wanted to do was to change the colors of the various cells, I do not need to activate any sheets, I can access all of these cells through the object model. I do not need to know the active cell or the active sheet or even the active workbook.

Beachten Sie, dass alles, was ich tun wollte, war, um die Farben der verschiedenen Zellen zu ändern, brauche ich nicht, um alle Blätter zu aktivieren, kann ich alle diese Zellen über das Objektmodell zugreifen. Brauche ich nicht, um die aktive Zelle oder das aktive Blatt oder auch die aktive Arbeitsmappe kennen.

<font face="Courier New", Monospace><br><SPAN style="color:#00007F">Sub</SPAN> NotUsingWindowObjectDemonstration()<br><br>    <SPAN style="color:#00007F">Dim</SPAN> strMsg  <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>        wbNew   <SPAN style="color:#00007F">As</SPAN> Excel.Workbook, _<br>        i%<br><br>    <SPAN style="color:#00007F">Set</SPAN> wbNew = Workbooks.Add(XlWBATemplate.xlWBATWorksheet)<br>    <SPAN style="color:#00007F">With</SPAN> wbNew<br>        <SPAN style="color:#00007F">With</SPAN> .Worksheets<br>            .Add After:=.Item(.Count)<br>            .Add After:=.Item(.Count)<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> i = 1 <SPAN style="color:#00007F">To</SPAN> 3<br>            <SPAN style="color:#00007F">With</SPAN> .Worksheets(i)<br>                <SPAN style="color:#00007F">With</SPAN> .Range(.Cells(1, 1), .Cells(i * 3, i * 3))<br>                    <SPAN style="color:#00007F">With</SPAN> .Interior<br>                        .ThemeColor = xlThemeColorAccent1 + (i - 1)<br>                        .Pattern = xlSolid<br>                        .PatternColorIndex = xlAutomatic<br>                        .TintAndShade = 0.8<br>                        .PatternTintAndShade = 0<br>                    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>                <SPAN style="color:#00007F">With</SPAN> .Cells(i, i)<br>                    .Interior.TintAndShade = 0.4<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> i<br>        <SPAN style="color:#00007F">With</SPAN> .Worksheets(1)<br>            <SPAN style="color:#00007F">With</SPAN> .Range("D4:G8")<br>                <SPAN style="color:#00007F">With</SPAN> .Interior<br>                    .ThemeColor = xlThemeColorAccent4<br>                    .Pattern = xlSolid<br>                    .PatternColorIndex = xlAutomatic<br>                    .TintAndShade = 0.8<br>                    .PatternTintAndShade = 0<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">With</SPAN> .Cells(5, 5)<br>                .Interior.TintAndShade = 0.4<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            .Activate<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>    <SPAN style="color:#007F00">'// worksheet 1</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>    <SPAN style="color:#007F00">'// wbNew</SPAN><br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><br><br><br><br></FONT>
 
Upvote 0
Hello
. I’ve worked through wot you sent a few times. I think I follow and understand everything. I think perhaps I roughly understood the main points already but it helped to get it clear in my head again. I Also learnt some useful new stuff including practice with Activesheet and distinguishing between activating and selecting. I used your code to produce the following code which I hope demonstrates the point of the “effective” “AlanActivecell” of which there can “effectively” be lots of at the same time!!
. I’ve learnt a lot. Thanks again for your efforts
Alan

( P.s. 1) you probably meant to write … “ wbNew.Close true “ instead of “ wbNew.Close False “ somewhere
. 2) I think the word “ Windows “ was missing in a message box or two

. 3) I’m not quite sure what the line “ .Parent.Worksheets(i).Activate “ does? )



Hallo
. Ich bin jetzt eine paar Mal durch ihren Code und denk ich verstehe es zum größte teile. Evtl. hab ich schon sehr grob verstanden die Haupt Sachen das sie mir erklären wollte aber es hat Gehilfen es nochmal Klar in meine Kopf zu kriegen. Das gesagt ich habe viele anderer sehr gute Sachen gelernt, u.a. Habe zu erste mal mit Activesheet beschäftigt und es war gut um zu unterscheide zwischen aktivieret Cell und selektierend cell . Ich habe ihren Code bemutz um die folgender Code zu schreiben. Ich denke das hilft noch zu erklär meine Idee das man “quasi” viele active cells haben kann gleich zeitig!!
. Ich Habs viele gelernt. Vielen danke für ihren muhe
Alan

( P.s.
1) sie haben evtl. gemeint zu schreiben … “ wbNew.Close True “ statt “ wbNew.Close False “ irgendwo
. 2) Evtl. fehlt die Worte “ Windows “ in einiger Message box

. 3) Ich war nicht ganz sicher was “
.Parent.Worksheets(i).Activate “ tut?

Code:
[/COLOR][COLOR=#0000FF]Sub[/COLOR][COLOR=#000000] AlanActiveCellDemonstration()
 
[/COLOR][COLOR=#0000FF]Dim [/COLOR][COLOR=#000000]i As [/COLOR][COLOR=#0000FF]Integer[/COLOR][COLOR=#000000]
 
[/COLOR][COLOR=#008000]' #1  This following part simply puts some numbers in some cells for demonstration purposes[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#0000FF]For [/COLOR][COLOR=#000000]i = 1 [/COLOR][COLOR=#0000FF]To[/COLOR][COLOR=#000000] 4 [/COLOR][COLOR=#0000FF]Step[/COLOR][COLOR=#000000] 1
    Excel.Application.ThisWorkbook.Worksheets.Item(1).Cells(i, i).Range("A1").Value = i
[/COLOR][COLOR=#0000FF]Next[/COLOR][COLOR=#000000] i
[/COLOR][COLOR=#008000]'
' #2  This following part adds some windows by the method demonstrated by Greg Truby
'    (Alternatively I could simply, as in my work, open 4 different files)[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#0000FF]For i[/COLOR][COLOR=#000000] = 1 [/COLOR][COLOR=#0000FF]To [/COLOR][COLOR=#000000]3 [/COLOR][COLOR=#0000FF]Step[/COLOR][COLOR=#000000] 1
    Application.ThisWorkbook.NewWindow
[/COLOR][COLOR=#0000FF]Next[/COLOR][COLOR=#000000] i
Application.ThisWorkbook.Windows.Arrange xlArrangeStyleTiled
[/COLOR][COLOR=#008000]'
' #3  This following part does what I would do manually, that is to say going through the
'   Windows and picking out what info I want by clicking on the relevant cell[/COLOR][COLOR=#000000]
         [/COLOR][COLOR=#0000FF]For[/COLOR][COLOR=#000000] i = 1 [/COLOR][COLOR=#0000FF]To[/COLOR][COLOR=#000000] 4[/COLOR][COLOR=#0000FF] Step[/COLOR][COLOR=#000000] 1
            [/COLOR][COLOR=#0000FF]With[/COLOR][COLOR=#000000] Windows.Item(i)
                .Activate
                .ActiveSheet.Cells(i, i).Range("a1").Activate[/COLOR][COLOR=#008000] ' I could use select here
'                   as Select or Activate seems to have the same effect[/COLOR][COLOR=#000000]
           [/COLOR][COLOR=#0000FF] End With[/COLOR][COLOR=#000000]
      [/COLOR][COLOR=#0000FF]  Next[/COLOR][COLOR=#000000] i
[/COLOR][COLOR=#008000]'
'  #4   This following part demonstrates the point I was making about "effectively" having
'   lots of active cells at the same time: Although technically i am using the windows
'   active cell, if I had different worksheets or different workbooks in the windows
'   then i have "effectively" 4 different workbooks or worksheets in front of me,
'   and "effectively" they all have their own active cell
'     My 4 "effective" active cells can be accessed, and its properties and functions
'   used, for example in further calculations,[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#0000FF]Dim[/COLOR][COLOR=#000000] SumOfAlanActiveCellsValue As[/COLOR][COLOR=#0000FF] Integer[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#0000FF]Let[/COLOR][COLOR=#000000] SumOfAlanActiveCellsValue = 0
For i = 1 To 4 Step 1
[/COLOR][COLOR=#0000FF]Debug.Print [/COLOR][COLOR=#000000]Windows.Item(i).Caption & " Last Activated cell value" & Windows.Item(i).ActiveCell.Value
[/COLOR][COLOR=#0000FF]Let[/COLOR][COLOR=#000000] SumOfAlanActiveCellsValue = SumOfAlanActiveCellsValue + Windows.Item(i).ActiveCell.Value
[/COLOR][COLOR=#0000FF]Next[/COLOR][COLOR=#000000] i
[/COLOR][COLOR=#0000FF]Debug.Print[/COLOR][COLOR=#000000] SumOfAlanActiveCellsValue
[/COLOR][COLOR=#008000]'[/COLOR][COLOR=#000000]
[/COLOR][COLOR=#0000FF]End Sub [/COLOR][COLOR=#008000]' AlanActiveCellDemonstration()[/COLOR][COLOR=#000000][/COLOR][COLOR=#000080]
 
Upvote 0
I think we've probably covered all we can here. A couple of final points:
  1. There are two types of Windows collections:
    • The general collection of all the windows in Excel
    • A workbook's windows collection of those windows for that specific workbook.
    You appear to be using the two collections interchangeably.
  2. It is dangerous to loop the general windows collection and .activate items in that window. You may accidentally reference a hidden window. If you .activate a hidden window it becomes unhidden. If you attempt to .activate the activecell of a hidden window you will raise an error.
  3. No, the wbNew.Close False was intentional. It was a throw-away workbook, no need to keep it.
  4. Yes, the word "windows" was missing from one message.
  5. The parent of the window object there was the workbook, not the application. An alternate syntax might have been
    Code:
    With .Windows(.Name & ":" & 4)
        .Activate
    End With
    .Worksheets(1).Activate


Ich denke, wir haben wahrscheinlich alle, die wir hier behandelt. Ein paar letzte Punkte:
  1. Es gibt zwei Arten von Windows- Sammlungen:
    • Die allgemeine Sammlung aller Fenster in Excel
    • Eine Arbeitsmappe Windows Sammlung von diesen Fenstern für diesen speziellen Arbeitsmappe.
    Sie scheinen sich mit den beiden Sammlungen austauschbar.
  2. Es ist gefährlich, die allgemeine Schleife Windows Sammlung und .Activate Elemente in diesem Fenster. Sie können versehentlich Referenz ein ausgeblendetes Fenster. Wenn Sie .Activate ein ausgeblendetes Fenster aktivieren wird eingeblendet. Wenn Sie .Activte die .ActiveCell von einem versteckten Fenster wird eine Fehler erhöhen.
  3. Nein, die wbNew.Close falsch vorsätzliche war . Es war ein Wegwerf-Arbeitsmappe , keine Notwendigkeit, es zu behalten.
  4. Ja, das Wort "Fenster" wurde von einer Nachricht fehlt.
  5. Das übergeordnete Objekt des Fensters gab es die Arbeitsmappe, nicht die Anwendung. Eine alternative Syntax könnte
    Code:
    With .Windows(.Name & ":" & 4)
        .Activate
    End With
    .Worksheets(1).Activate
 
Upvote 0
Hi Greg
Great, Super,! Thanks for all your Help, I’ve learnt lots and probably learn more when I go through and think carefully about all you said
Cheers,
Alan


Hi Greg
Alles klar!, Super Ich hab’s viele gelernt
Danke nochmal
Alan.
 
Upvote 0
Re :- Copying Code into a Thread or Reply without losing (colour) format.


To Greg Truby
Hello, just a quick one this time!!:- Is it easy to explain how you copied the code in one of your answers ( the one where you didn’t use the code tags...... http://www.mrexcel.com/forum/questi...rch-workbooks-oder-windows-oop-methode-2.html ) and were able to keep the format (for example green color in the comment). Or is it complicated and I must learn all about HMTL, XBHMTL or whatever it is?? , ( as suggested to me by MrExcel MVP Moderator Peter_SSs in the Thread / Link ( http://www.mrexcel.com/forum/about-board/780464-re-text-format-forums-o00o-`-_-`-o00o.html )
Thanks, Alan
P.s. I tried to send this “Private” to you ( http://www.mrexcel.com/forum/private.php?do=newpm&u=5023 )but it didn’t work – your messages were “Full”. This question is not urgent so Don’t answer if you’re too busy!!


An Greg Truby,
Hi, ich bin wieder, nur kurz dieses mall!!:- Können sie mir einfach erklären wie sie ihren Code Kopieret in einer deine Antwort (ohne die Code tags……. http://www.mrexcel.com/forum/questi...rch-workbooks-oder-windows-oop-methode-2.html ), und die Formattieren (Zb. Grün Kommentar b) behalten habe?.. Oder gibt’s keine einfach erklären und ich muss alles über HTML VBHTML, oder was immer lernen davor?? (Wie zu mir bei MrExcel MVP Moderator Peter_SSs empfohlen in die Thread / Link (
http://www.mrexcel.com/forum/about-board/780464-re-text-format-forums-o00o-%60-_-%60-o00o.html )
Danke, Alan
P.s. Ich Habs versuchte diese Fragen direkt an sie „Private“ zu schreiben (
http://www.mrexcel.com/forum/private.php?do=newpm&u=5023 ) aber ihren Nachrichten war voll. – Also falls sie sehr beschäftigt bin, dann ignorieren dies fragen, weil es nicht zu wichtig ist.
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top