Consulting

Results 1 to 5 of 5

Thread: Modifing shapes while presentation is active

  1. #1
    VBAX Newbie
    Joined
    Dec 2019
    Posts
    3
    Location

    Modifing shapes while presentation is active

    Hi everybody,

    sorry for my english, i'll do my best to explain what my problem is.

    I have datas in a txt file and I want to get and show them in a powerpoint presentation.
    Data in txt are modified by an excel spreadsheet which has the same location as the powerpoint file but thery are opened on different PC.

    Coming to the VBA code I'm trying to wirte the problem is that as I process the code step by step in debug mode everything works fine, as I try to execute the code under a slide change event (so the presentation runs) I'm not able anymore to select shapes and modify text, colors etc.

    Can anybody give me a hint?
    Thanks,

    vasomik

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,898
    Location
    I would start by posting the code you have.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Newbie
    Joined
    Dec 2019
    Posts
    3
    Location
    Quote Originally Posted by John Wilson View Post
    I would start by posting the code you have.
    Thanks for your reply, this is my code:

    Sub GetDataFromTxt()
    
    
    Dim PathX
    Dim ObjName, EtichettaStanza, ColoreTipoStanza, ColoreStatoStanza, NumeroStanza, TipoStanza, NumeroPosti, StatoStanza, StanzaFemmine
    Dim Arr_ColoreStatoStanza
    Dim TotalePosti
    Dim PostiOccupati
    Dim PersonaleMaschile
    Dim PersonaleFemminile
    Dim StanzeGaslini
    Dim NumeriStanzeGaslini
    Dim StanzeInagibili
    Dim PostiInagibili
    Dim NumeriStanzeInagibili
    Dim Statistiche
    Dim LedStanza
    Dim X As Integer
    
    
    '***************************
    'CASERMA 2 PIANO LATO SUD**
    '***************************
    
    
    X = 4 'Contatore per gli oggetti nel do while
    
    
    ActivePresentation.Slides(5).Select 'Seleziono la slide su cui lavorare
    
    
    PathX = ActivePresentation.Path
    
    
    Open PathX & "\2PianoCaserma.txt" For Input As #1
    
    
    Do While Not EOF(1)
       Input #1, NumeroStanza
       Input #1, TipoStanza
       Input #1, StatoStanza
       Input #1, NumeroPosti
       Input #1, StanzaFemmine
       Input #1, ColoreTipoStanza
       Input #1, ColoreStatoStanza
       Input #1, ObjName
       Input #1, EtichettaStanza
       
       'Input #1, Statistiche
       'Input #1, TotalePosti
       'Input #1, PostiOccupati
       'Input #1, PersonaleMaschile
       'Input #1, PersonaleFemminile
       'Input #1, StanzeGaslini
       'Input #1, StanzeInagibili
       
       If NumeroStanza = 782 Then
        a = 1
       End If
       
       If Mid(ColoreStatoStanza, 1, 1) = "," Then
        ColoreStatoStanza = Mid(ColoreStatoStanza, 2)
       End If
       
       'Assegno i nomi agli oggetti
       ActivePresentation.Slides(5).Shapes(X).Name = EtichettaStanza 'Assegno il nome all'ovale (Shape 3 nella slide)
       ActivePresentation.Slides(5).Shapes(X).Select
       ActivePresentation.Slides(5).Shapes(X + 1).Name = ObjName
       ActivePresentation.Slides(5).Shapes(X + 1).Select
       
       ActivePresentation.Slides(5).Shapes(EtichettaStanza).Fill.ForeColor.RGB = ColoreTipoStanza 'RGB(Red:=230, Green:=126, Blue:=34)
       ActivePresentation.Slides(5).Shapes(EtichettaStanza).Fill.BackColor.RGB = RGB(Red:=105, Green:=143, Blue:=38)
       ActivePresentation.Slides(5).Shapes(EtichettaStanza).Fill.TwoColorGradient Style:=msoGradientHorizontal, Variant:=2
       'ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = RGB(Red:=15, Green:=143, Blue:=38)
       ActivePresentation.Slides(5).Shapes(ObjName).TextFrame.TextRange.Text = NumeroStanza
       ActivePresentation.Slides(5).Shapes(ObjName).TextFrame.MarginBottom = 50
       ActivePresentation.Slides(5).Shapes(ObjName).TextFrame.MarginLeft = 10
       
       If NumeroPosti = 1 Then
            LedStanza = "LED" & NumeroStanza & "_1"
            ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(X + 3).Select
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = ColoreStatoStanza 'RGB(Red:=15, Green:=143, Blue:=38)
       End If
       If NumeroPosti = 2 Then
            If StatoStanza = "I" Then
                LedStanza = "LED" & NumeroStanza & "_1"
                ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(0) 'RGB(Red:=15, Green:=143, Blue:=38)
                LedStanza = "LED" & NumeroStanza & "_2"
                ActivePresentation.Slides(5).Shapes(X + 3 + 1).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(1) 'RGB(Red:=15, Green:=143, Blue:=38)
            Else
                Arr_ColoreStatoStanza = Split(ColoreStatoStanza, ",")
                LedStanza = "LED" & NumeroStanza & "_1"
                ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(0) 'RGB(Red:=15, Green:=143, Blue:=38)
                LedStanza = "LED" & NumeroStanza & "_2"
                ActivePresentation.Slides(5).Shapes(X + 3 + 1).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(1) 'RGB(Red:=15, Green:=143, Blue:=38)
            End If
            X = X + 1
       End If
       If NumeroPosti = 3 Then
            If StatoStanza = "I" Then
                LedStanza = "LED" & NumeroStanza & "_1"
                ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = ColoreStatoStanza 'RGB(Red:=15, Green:=143, Blue:=38)
                LedStanza = "LED" & NumeroStanza & "_2"
                ActivePresentation.Slides(5).Shapes(X + 3 + 1).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = ColoreStatoStanza 'RGB(Red:=15, Green:=143, Blue:=38)
                LedStanza = "LED" & NumeroStanza & "_3"
                ActivePresentation.Slides(5).Shapes(X + 3 + 2).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = ColoreStatoStanza 'RGB(Red:=15, Green:=143, Blue:=38)
            Else
                Arr_ColoreStatoStanza = Split(ColoreStatoStanza, ",")
                LedStanza = "LED" & NumeroStanza & "_1"
                ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(0) 'RGB(Red:=15, Green:=143, Blue:=38)
                LedStanza = "LED" & NumeroStanza & "_2"
                ActivePresentation.Slides(5).Shapes(X + 3 + 1).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(1) 'RGB(Red:=15, Green:=143, Blue:=38)
                LedStanza = "LED" & NumeroStanza & "_3"
                ActivePresentation.Slides(5).Shapes(X + 3 + 2).Name = LedStanza
                ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(2) 'RGB(Red:=15, Green:=143, Blue:=38)
            End If
            X = X + 2
       End If
       If NumeroPosti = 4 Then
        If StatoStanza = "I" Then
            LedStanza = "LED" & NumeroStanza & "_1"
            ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(0) 'RGB(Red:=15, Green:=143, Blue:=38)
            LedStanza = "LED" & NumeroStanza & "_2"
            ActivePresentation.Slides(5).Shapes(X + 3 + 1).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(1) 'RGB(Red:=15, Green:=143, Blue:=38)
            LedStanza = "LED" & NumeroStanza & "_3"
            ActivePresentation.Slides(5).Shapes(X + 3 + 2).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(2) 'RGB(Red:=15, Green:=143, Blue:=38)
            LedStanza = "LED" & NumeroStanza & "_4"
            ActivePresentation.Slides(5).Shapes(X + 3 + 3).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(3) 'RGB(Red:=15, Green:=143, Blue:=38)
        Else
            Arr_ColoreStatoStanza = Split(ColoreStatoStanza, ",")
            LedStanza = "LED" & NumeroStanza & "_1"
            ActivePresentation.Slides(5).Shapes(X + 3).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(0) 'RGB(Red:=15, Green:=143, Blue:=38)
            LedStanza = "LED" & NumeroStanza & "_2"
            ActivePresentation.Slides(5).Shapes(X + 3 + 1).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(1) 'RGB(Red:=15, Green:=143, Blue:=38)
            LedStanza = "LED" & NumeroStanza & "_3"
            ActivePresentation.Slides(5).Shapes(X + 3 + 2).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(2) 'RGB(Red:=15, Green:=143, Blue:=38)
            LedStanza = "LED" & NumeroStanza & "_4"
            ActivePresentation.Slides(5).Shapes(X + 3 + 3).Name = LedStanza
            ActivePresentation.Slides(5).Shapes(LedStanza).Fill.ForeColor.RGB = Arr_ColoreStatoStanza(3) 'RGB(Red:=15, Green:=143, Blue:=38)
        End If
        X = X + 3
       End If
    
    
       
       X = X + 4
    Loop
    
    
    Close #1 'Chiusura File
    
    
    
    
    End Sub
    As the user make modifications on excel file and sent data to txt, I would like the code to be executed every 5 miuntes while presentation is running.
    Note that both files, the excel one and powerpoint, are located in the same folder but the excels gets opened on user's PC while the powerpoint on another one in a intranet.

    vasomik

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,898
    Location
    Code wqhich includes .Select will never work in slide show mode. You cannot select anything in show mode.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Newbie
    Joined
    Dec 2019
    Posts
    3
    Location
    Quote Originally Posted by John Wilson View Post
    Code wqhich includes .Select will never work in slide show mode. You cannot select anything in show mode.
    Yes, I've read this somewhere.
    If you understood what I need to do, can you give an idea on how to solve the problem? Even if it is necessary to change mind!!

Posting Permissions

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