cerco di prendere uno screenshot di un foglio di lavoro in Excel con codice VBA e poi salvarlo in un percorso specificato, ma non riesco a salvare in modo corretto ...Excel VBA salvare screenshot
Sub My_Macro(Test, Path)
Dim sSheetName As String
Dim oRangeToCopy As Range
Dim FirstCell As Range, LastCell As Range
Worksheets(Test).Activate
Set LastCell = Cells(Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Column)
Set FirstCell = Cells(Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlRows, _
SearchDirection:=xlNext, LookIn:=xlValues).Row, _
Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, LookIn:=xlValues).Column)
sSheetName = Test ' worksheet to work on
With Worksheets(sSheetName)
.Range(FirstCell, LastCell).CopyPicture xlScreen, xlPicture
.Export Filename:=Path + Test + ".jpg", Filtername:="JPG"
End With
End Sub
Excel non vuole eseguire il metodo. Esporta ... direttamente dopo aver preso lo screenshot. Così ho provato a incollare l'immagine in un nuovo grafico. Excel salvare il disegno grafico al posto giusto con un grafico sulla mia immagine ... ho anche cercato di incollarlo in un foglio di lavoro di Excel temporaneo, ma non vuole esportare ...
Qualsiasi idea
Non credo che JPG è un formato di esportazione valida per Excel (vedere l'elenco quando si tenta di esportare un foglio di Excel manualmente) Quindi Excel non sa cosa fare quando si forza di farlo nel codice . – Tom
Vedi qui: http://www.mrexcel.com/forum/excel-questions/233108-visual-basic-applications-code-export-image-file-preferably-jpg.html –