Consulting

Results 1 to 7 of 7

Thread: where are these two excel workbooks coming from

  1. #1
    VBAX Regular
    Joined
    Aug 2014
    Posts
    18
    Location

    where are these two excel workbooks coming from

    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

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    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

  3. #3
    VBAX Regular
    Joined
    Aug 2014
    Posts
    18
    Location
    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.

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    gruenSelbst As String
    ???

    did you consider

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

  5. #5
    VBAX Regular
    Joined
    Aug 2014
    Posts
    18
    Location
    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

  6. #6
    VBAX Regular
    Joined
    Aug 2014
    Posts
    18
    Location
    problem solved, but thx to you again snb for helping me.

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Start at the beginning in VBA....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •