Set range for XL workbook cell A1

Viewed 40

I am new in Python. I guess this is something very simple, I searched forums, but my situation is a little different.

In need to set a to sheet cell ("B1") for example And later use it as TextRange. Most people on forums telling how to do it with openpyxl.load_workbook Can't I do set wb , ws , cell with excel.workbook.open?

I tried openpyxl also as you can see on commented lines.But was not succeful.

    presentation=PowerPoint.Presentations.Add(True)
    wb=Excel.Workbooks.Open(Filename=r"\Python project\forPPT.xlsx",ReadOnly=1,UpdateLinks=False)
    #wb = openpyxl.load_workbook(r"\Python project\forPPT.xlsx")
    #sh = wb.active
    for ws in wb.Worksheets:
    for chart in ws.ChartObjects():
    # Copying all the charts from excel
        chart.Activate()
        chart.Copy()  
        
    #a = sh.cell(row=1,column=2).Value
    #b = sh.cell(row=1,column=5).Value

    Slide=presentation.Slides.Add(presentation.Slides.Count+1,12)
    Slide.Shapes.PasteSpecial(11)

    
    # Need to use that ranges later in Text.Range.Text
    textbox=Slide.Shapes.AddTextbox(1,100,100,200,300)
    textbox.TextFrame.TextRange.Text= a 
0 Answers
Related