Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
696to700
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
696to700
696to700
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Kop. in andere Mappe "BILD"

Kop. in andere Mappe "BILD"
22.11.2005 17:13:55
angela
Hallo
habe ein Code mit dem ich ein Tab in eine andere Mappe kopiere.
Leider nimmt er die 2 Bilder nicht mit. das eine (Bild1)befindet sich K2:N5,
das andere (Bild2)befindet sich O53:Q53.
Das Makro stelle ich mal hintenran.
Vielleicht habt Ihr eine Idee, würde mich freuen.
Mfg. Angela
Public

Sub PPP()
'Makro am 14.11.2005 von Peter erstellt
Application.ScreenUpdating = False    ' Anzeige am Bildschirm deaktivieren
Worksheets("Hand").Visible = True
Sheets("Hand").Select
Dim sName As String
Dim sDatum As String
Dim sFolder As String
Dim lSheetsCount As Long
lSheetsCount = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
With ActiveSheet
sName = Cells(5, 3)
sDatum = Day(Cells(7, 14).Value) & ".-" & Cells(7, 19).Value
Range("A1:W54").Copy
Workbooks.Add
With ActiveSheet.Cells(1, 1)
.PasteSpecial Paste:=xlPasteColumnWidths ' Spaltenbreite
.PasteSpecial Paste:=xlPasteValues ' Werte
.PasteSpecial Paste:=xlFormats ' Formate
ActiveWindow.DisplayZeros = False
'.Select
End With
End With
Columns("X:IV").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll Down:=36
Rows("55:170").Select
'Range("C55").Activate
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
ActiveWindow.ScrollRow = 34
ActiveWindow.ScrollRow = 33
ActiveWindow.ScrollRow = 32
ActiveWindow.ScrollRow = 31
ActiveWindow.ScrollRow = 30
ActiveWindow.ScrollRow = 29
ActiveWindow.ScrollRow = 28
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 26
ActiveWindow.ScrollRow = 25
ActiveWindow.ScrollRow = 24
ActiveWindow.ScrollRow = 23
ActiveWindow.ScrollRow = 22
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 17
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 12
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
End With
Application.SheetsInNewWorkbook = lSheetsCount
sFolder = Trim$(fncGetFolder(, , "C:\"))
If sFolder <> "" Then
ActiveWorkbook.SaveAs sFolder & "\" & sName & "-" & sDatum & ".xls"
ActiveWindow.Close
End If
Sheets("Hand").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True    ' Anzeige am Bildschirm aktivieren
End Sub

18
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Kop. in andere Mappe "BILD"
22.11.2005 17:29:35
Josef
Hallo Angela!
Warum so kompliziert?
Sub PPP()
Dim sName As String
Dim sDatum As String
Dim sFolder As String
Dim wkbNew As Workbook

Application.ScreenUpdating = False ' Anzeige am Bildschirm deaktivieren

With Worksheets("Hand")
  .Visible = xlSheetVisible
  sName = .Cells(5, 3)
  sDatum = Day(.Cells(7, 14).Value) & ".-" & .Cells(7, 19).Value
  .Copy
  .Visible = xlSheetVeryHidden
End With

Set wkbNew = ActiveWorkbook

sFolder = Trim$(fncGetFolder(, , "C:\"))

If sFolder <> "" Then
  wkbNew.SaveAs sFolder & "\" & sName & "-" & sDatum & ".xls"
  wkbNew.Close
End If

Application.ScreenUpdating = True ' Anzeige am Bildschirm aktivieren

End Sub


'******************************
'* Gruß Sepp
'*
'* Rückmeldung wäre nett!
'******************************

Anzeige
AW: Kop. in andere Mappe "BILD"
22.11.2005 17:46:35
angela
Hallo Sepp
nett das Du so schnell geantwortet hast.
Leider gehts nicht. Habe mal alles reinkopiert was ich dazu habe.
Er macht ja alles richtig, ausser das er Bild1 u. Bild2 nicht mitnimmt.
Mfg. Angela
Option Explicit
Private Declare Function MoveWindow Lib "user32" ( _
ByVal hwnd As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" ( _
ByVal nIndex As Long) As Long
Private Declare Function GetWindowRect Lib "user32" ( _
ByVal hwnd As Long, _
ByRef lpRect As RECT) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" ( _
ByRef lpbi As InfoT) As Long
Private Declare Function CoTaskMemFree Lib "ole32" ( _
ByVal hMem As Long) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" ( _
ByVal lpStr1 As String, _
ByVal lpStr2 As String) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" ( _
ByVal pList As Long, _
ByVal lpBuffer As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassname As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal Msg As Long, _
ByRef wParam As Any, _
ByRef lParam As Any) As Long
Private Type InfoT
hwnd As Long
Root As Long
DisplayName As Long
Title As Long
Flags As Long
FName As Long
lParam As Long
Image As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Enum BIF_Flag
BIF_RETURNONLYFSDIRS = &H1
BIF_DONTGOBELOWDOMAIN = &H2
BIF_STATUSTEXT = &H4
BIF_RETURNFSANCESTORS = &H8
BIF_EDITBOX = &H10
BIF_VALIDATE = &H20
BIF_NEWDIALOGSTYLE = &H40
BIF_BROWSEINCLUDEURLS = &H80
BIF_BROWSEFORCOMPUTER = &H1000
BIF_BROWSEFORPRINTER = &H2000
BIF_BROWSEINCLUDEFILES = &H4000
BIF_SHAREABLE = &H8000
End Enum
Private Const SM_CXFULLSCREEN = &H10
Private Const SM_CYFULLSCREEN = &H11
Private Const BFFM_SETSELECTION = &H466
Private Const BFFM_INITIALIZED = &H1
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"
Private s_BrowseInitDir As String

Private Function fncGetFolder( _
Optional ByVal sMsg As String = "Bitte wählen Sie ein Verzeichnis", _
Optional ByVal lFlag As BIF_Flag = BIF_RETURNONLYFSDIRS, _
Optional ByVal sPath As String = "C:\") As String
Dim xl As InfoT, IDList As Long, RVal As Long, FolderName As String
s_BrowseInitDir = sPath
With xl
.hwnd = FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption)
.Root = 0
.Title = lstrcat(sMsg, "")
.Flags = lFlag
.FName = FuncCallback(AddressOf BrowseCallback)
End With
IDList = SHBrowseForFolder(xl)
If IDList <> 0 Then
FolderName = Space(256)
RVal = SHGetPathFromIDList(IDList, FolderName)
CoTaskMemFree (IDList)
FolderName = Trim$(FolderName)
FolderName = Left$(FolderName, Len(FolderName) - 1)
End If
fncGetFolder = FolderName
End Function


Private Function BrowseCallback( _
ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
If uMsg = BFFM_INITIALIZED Then
Call SendMessage(hwnd, BFFM_SETSELECTION, ByVal 1&, ByVal s_BrowseInitDir)
Call CenterDialog(hwnd)
End If
BrowseCallback = 0
End Function


Private Function FuncCallback(ByVal nParam As Long) As Long
FuncCallback = nParam
End Function


Private Sub CenterDialog(hwnd As Long)
Dim WinRect As RECT, ScrWidth As Integer, ScrHeight As Integer
Dim DlgWidth As Integer, DlgHeight As Integer
GetWindowRect hwnd, WinRect
DlgWidth = WinRect.Right - WinRect.Left
DlgHeight = WinRect.Bottom - WinRect.Top
ScrWidth = GetSystemMetrics(SM_CXFULLSCREEN)
ScrHeight = GetSystemMetrics(SM_CYFULLSCREEN)
MoveWindow hwnd, (ScrWidth - DlgWidth) / 2, _
(ScrHeight - DlgHeight) / 2, DlgWidth, DlgHeight, 1
End Sub

Sub PPP()
'Makro am 14.11.2005 von Peter erstellt
Application.ScreenUpdating = False ' Anzeige am Bildschirm deaktivieren
Worksheets("Hand").Visible = True
Sheets("Hand").Select
Dim sName As String
Dim sDatum As String
Dim sFolder As String
Dim lSheetsCount As Long
lSheetsCount = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
With ActiveSheet
sName = Cells(5, 3)
sDatum = Day(Cells(7, 14).Value) & ".-" & Cells(7, 19).Value
'
Range("A1:W54").Copy
Workbooks.Add
With ActiveSheet.Cells(1, 1)
.PasteSpecial Paste:=xlPasteColumnWidths ' Spaltenbreite
.PasteSpecial Paste:=xlPasteValues ' Werte
.PasteSpecial Paste:=xlFormats ' Formate
ActiveWindow.DisplayZeros = False
'.Select
End With
End With
Columns("X:IV").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll Down:=36
Rows("55:170").Select
'Range("C55").Activate
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
ActiveWindow.ScrollRow = 34
ActiveWindow.ScrollRow = 33
ActiveWindow.ScrollRow = 32
ActiveWindow.ScrollRow = 31
ActiveWindow.ScrollRow = 30
ActiveWindow.ScrollRow = 29
ActiveWindow.ScrollRow = 28
ActiveWindow.ScrollRow = 27
ActiveWindow.ScrollRow = 26
ActiveWindow.ScrollRow = 25
ActiveWindow.ScrollRow = 24
ActiveWindow.ScrollRow = 23
ActiveWindow.ScrollRow = 22
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 17
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 15
ActiveWindow.ScrollRow = 14
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 12
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 10
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
End With
Application.SheetsInNewWorkbook = lSheetsCount
sFolder = Trim$(fncGetFolder(, , "C:\"))
If sFolder "" Then
ActiveWorkbook.SaveAs sFolder & "\" & sName & "-" & sDatum & ".xls"
ActiveWindow.Close
End If
Sheets("Hand").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True ' Anzeige am Bildschirm aktivieren
End Sub
Anzeige
AW: Kop. in andere Mappe "BILD"
22.11.2005 21:37:43
Josef
Hallo Angela!
Bevor wir kompliziert die Bilder einzeln kopieren, eine Frage.
Was funktioniert an meinem Code nicht?
'******************************
'* Gruß Sepp
'*
'* Rückmeldung wäre nett!
'******************************

AW: Kop. in andere Mappe "BILD"
Angela
Hallo Sepp
vielen Dank für deine Antwort.
Habe Dein Code in ein neues Modul kopiert, und mit F8 gestartet. Bekomme sofort die Meldung "Sub oder Funktion nicht definiert.
Mfg. Angela
Anzeige
AW: Kop. in andere Mappe "BILD"
22.11.2005 21:56:45
angela
ich nochmal
sFolder = Trim$(fncGetFolder(, , "C:\"))
die Zeile ist blau unterlegt
AW: Kop. in andere Mappe "BILD"
22.11.2005 21:59:10
Fred
Sepp hat vergessen, diese Funktion mitzuposten.
mfg Fred
?
22.11.2005 22:03:01
angela
hallo Fred
Welche Funktion hat Sepp vergessen?
Mfg Angela
AW: ?
22.11.2005 22:13:47
Fred
Hi,
diese: fncGetFolder
mfg Fred
AW: Kop. in andere Mappe "BILD"
22.11.2005 22:25:33
Josef
Hallo Angela!
Du musst den Code schon in dein bestehendes Modul, als ersatz von deinem Code, kopieren.
Deine dort hinterlegten Funktionen sind mir ja nicht bekannt gewesen!
PS: Glaubst du nicht, das du dich mit "VBA nur mit Rekorder",
mit diesem Projekt sebst ein bisschen übefordertst?
'******************************
'* Gruß Sepp
'*
'* Rückmeldung wäre nett!
'******************************

Anzeige
AW: Kop. in andere Mappe "BILD"
22.11.2005 22:44:13
angela
Hallo Sepp
vielen Dank, das Du Dich nochmal gemeldest hast, den Code habe ich schon zu den anderen getan, wahrscheinlich muß er noch einwenig angepasst werden.
Der alte Code funzt ja, es ging mir nur um die Bilder, das die mitgenommen werden in die neue Mappe.
Er nimmt dann die Bilder mit, aber färbt teile die vorher grün waren rot ein.
Mfg angela
AW: Kop. in andere Mappe "BILD"
22.11.2005 23:29:08
Josef
Hallo Angela!
Dann probier's mal so.
Sub PPP()
Dim objShape As Shape
Dim wsToCopy As Worksheet
Dim sName As String
Dim sDatum As String
Dim sFolder As String
Dim lSheetsCount As Long

lSheetsCount = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1

Application.ScreenUpdating = False ' Anzeige am Bildschirm deaktivieren

Set wsToCopy = Worksheets("Hand")

With wsToCopy
  .Visible = True
  sName = .Cells(5, 3)
  sDatum = Day(.Cells(7, 14).Value) & ".-" & .Cells(7, 19).Value
  .Range("A1:W54").Copy
End With

Workbooks.Add
With ActiveSheet
  With .Cells(1, 1)
    .PasteSpecial Paste:=xlPasteColumnWidths ' Spaltenbreite
    .PasteSpecial Paste:=xlPasteValues ' Werte
    .PasteSpecial Paste:=xlFormats ' Formate
  End With
  
  ActiveWindow.DisplayZeros = False
  
  For Each objShape In wsToCopy.Shapes
    If TypeName(objShape) = "Picture" Then
      objShape.Copy
      .Paste
      .Shapes(.Shapes.Count).Top = objShape.Top
      .Shapes(.Shapes.Count).Left = objShape.Left
    End If
  Next
  
  .Columns("X:IV").EntireColumn.Hidden = True
  
  With .Rows("55:170").Interior
    .ColorIndex = 15
    .Pattern = xlSolid
  End With
  
End With

Application.SheetsInNewWorkbook = lSheetsCount
sFolder = Trim$(fncGetFolder(, , "C:\"))
If sFolder <> "" Then
  ActiveWorkbook.SaveAs sFolder & "\" & sName & "-" & sDatum & ".xls"
  ActiveWindow.Close
End If
wsToCopy.Visible = xlSheetVeryHidden
Application.ScreenUpdating = True ' Anzeige am Bildschirm aktivieren
End Sub


'******************************
'* Gruß Sepp
'*
'* Rückmeldung wäre nett!
'******************************

Anzeige
AW: Kop. in andere Mappe "BILD"
23.11.2005 17:51:10
angela
Hallo Sepp
war einfach zu Müde gestern Abend um noch weiter zumachen.
Aber schön das Du nochmal geschrieben hast.
Nach testen Deiner letzten Version, habe ich das gleiche Problem.
Er nimmt einfach die Bilder nicht mit rüber, zum Teil verfärbt er die Zellen von Grün auf Rot. Wahrscheinlich geht es nicht, es gibt dort wohl keine Lösung.
Trotzdem vielen Dank, das Du so viel Geduld und Ausdauer mit mir hattest.
Liebe Grüße Angela
AW: Kop. in andere Mappe "BILD"
23.11.2005 19:00:41
Leo
Hi,
wenn du in den Eigenschaften der Bilder einstells: Von Zellgröße und Position abhängig
werden sie beim Kopieren der Zellen mitkopiert.
mfg Leo
Anzeige
AW: Kop. in andere Mappe "BILD"
23.11.2005 19:34:14
angela
Hallo Leo
Danke für die Antwort, ist so gewesen von Zelle u. Position,
trotzdem nimmt er sie nicht mit.
Mfg. Angela
AW: Kop. in andere Mappe "BILD"
23.11.2005 19:41:56
Leo
Hi,
lad die Mappe doch einfach mal hoch, sollte nur das Problemblatt enthalten.
mfg Leo
AW: Kop. in andere Mappe "BILD"
23.11.2005 20:39:48
angela
Hallo Leo
habe grade eine neue Datei erstellt, den Code reingeschoben, ein Bild aus Office genommen, es geht nicht, trotzdem ich auf Eigenschaft war u.Zelle u. Position angeklickt habe.
Er nimmt alles nur nicht das Bild mit.
Mfg. Angela
AW: Kop. in andere Mappe "BILD"
23.11.2005 21:46:14
Leo
Hi,
da das nicht normal ist, wäre es hilfreich, wenn du die Mappe mal hochladen würdest,
sonst können wir noch lange raten, woran es klemmt.
mfg Leo
Anzeige
AW: Kop. in andere Mappe "BILD"
23.11.2005 21:56:05
Angela
Hallo Leo
habe mal eine normale Mappe erstellt
einfach auf die Schaltfläche Drücken. Tab1 ist versteckt.
Mfg. Angela
https://www.herber.de/bbs/user/28661.xls

300 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige