vasomik
12-10-2019, 10:06 AM
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
John Wilson
12-10-2019, 11:43 AM
I would start by posting the code you have.
vasomik
12-11-2019, 12:28 AM
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
John Wilson
12-11-2019, 01:43 AM
Code wqhich includes .Select will never work in slide show mode. You cannot select anything in show mode.
vasomik
12-11-2019, 02:16 AM
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!!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.