PDA

View Full Version : [SOLVED] where are these two excel workbooks coming from



wolle271
09-05-2014, 06:30 AM
cheers guys,

im having the problem, that after running my code there are 2 excel workbooks opened up without anything in them.
im not even creating an(the code is being run from excel) excel app im just adding a workbook. then im adding some chart into it, change something and export it as an image. after that im closing the "activeworkbook".

this is my code:


Sub erstelleChart(gruenSelbst As String, rotFremd As String, location As String, filename As String) Dim diagrammPfad As String
Dim count As Integer
Dim objExcel As Object
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
diagrammPfad = "C:\Users\julian\Documents\Arbeit\Walter_Barwenczik\release\nurText\diagramm .xltx" '!
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Workbooks.Add (diagrammPfad)


For count = 2 To gruenSelbst 'Grüne Linie
ActiveChart.Shapes.Range(Array("Line 2")).Select
Selection.ShapeRange.IncrementLeft 82.5
Next count

For count = 2 To rotFremd 'Rote Linie
ActiveChart.Shapes.Range(Array("Line 1")).Select
Selection.ShapeRange.IncrementLeft 82.5
Next count

ActiveChart.Export filename:=location & "\" & filename, Filtername:="PNG"
ActiveWorkbook.Close
End Sub

snb
09-05-2014, 07:24 AM
The use of any loop is redundant: you don't use the variable.

this code suffices:


Sub M_snb()
ActiveChart.Shapes.Range(Array("Line 1","Line 2")).ShapeRange.IncrementLeft 82.5
end sub

wolle271
09-05-2014, 07:37 AM
well, first of all, the for your reply. i do need the loop because the increment-task needs to be repeated depeneding on the values of grünSelbst and rotFremd.

snb
09-05-2014, 08:10 AM
gruenSelbst As String

???

did you consider


gruenSelbst As double
(....).ShapeRange.IncrementLeft 82.5 *gruenSelbst

wolle271
09-05-2014, 08:13 AM
well this doesnt have anything to do with my Problem. those are strings cause i found it easier to work with the values when they are declared AS string

wolle271
09-05-2014, 09:02 AM
problem solved, but thx to you again snb for helping me.

snb
09-05-2014, 11:20 AM
Start at the beginning in VBA....