PPT VBA: Automatically rename saved file based on cell value of a table

Diskutiere und helfe bei PPT VBA: Automatically rename saved file based on cell value of a table im Bereich Microsoft Office im Windows Info bei einer Lösung; Hello all,I have found a working macro on the Internet that saves my large number of PowerPoint files each time in a new file name. The special thing... Dieses Thema im Forum "Microsoft Office" wurde erstellt von MarcelNM, 26. April 2023.

  1. MarcelNM
    MarcelNM Gast

    PPT VBA: Automatically rename saved file based on cell value of a table


    Hello all,I have found a working macro on the Internet that saves my large number of PowerPoint files each time in a new file name. The special thing is that the title of slide 1 is used as file name for each according powerpoint file.I also have a table 2 rows, 5 columns on slide 1 that contains data.I would like to add the cell value from row 2, column 5 to the file name to be saved in addition to the title.E.g. save name could be: "Title_1234A345.pptx"Below you see the working macro for the title. I would like to extend this macro to also sav
     
  2. MarcelNM Win User

    PPT VBA: Automatically rename saved file based on cell value of a table

    Thanks Abdal for your quick reply.
    Your code works!
    In the beginning, the code did not get the value I wanted to have.
    I found out, even though it´s my first colom if you "look" at the slide, it´s colum 6.
    So I changed Set tbl = oPres.Slides(1). Shapes(1). Table to [...] Shapes(6).Table.
    I just tried out by starting 2, 3, 4, ...
    What is the "right" way to get the id of the shape?
    I found that picture below, but this seems not to be the right way.
    Thank you,
    Marcel
    [​IMG]
  3. Md Abdal Khan Win User

    PPT VBA: Automatically rename saved file based on cell value of a table

    Hello

    I am Abdal and I would be glad to help you with your question.

    To add the cell value of row 2 and column 5 to the file name, you can simply retrieve the value from the table and append it to the strName variable before saving the file.

    Here's the modified code:

    Sub resave()

    Dim strDate As String
    Dim strFilePath As String
    Dim L As Long
    Dim iPos As Integer
    Dim strName As String
    Dim strSuffix As String
    Dim oPres As Presentation
    Const Folderpath As String = "C:\Users\xxx\"
    Const strSpec As String = "*.ppt*"
    On Error Resume Next
    MkDir Folderpath & "\Resaved Files"
    'First match
    strFilePath = Dir$(Folderpath & strSpec)
    While strFilePath <> ""
    strName = ""
    Set oPres = Presentations.Open(FileName:=Folderpath & strFilePath, WithWindow:=False)
    iPos = InStrRev(oPres.Name, ".")
    strSuffix = Mid(oPres.Name, iPos)
    strName = oPres.Slides(1). Shapes.Title.TextFrame.TextRange
    strName = clean(strName)

    ' Get value from cell(2,5) of the first table on slide 1
    Dim tbl As Table
    Set tbl = oPres.Slides(1). Shapes(1). Table
    Dim cellValue As String
    cellValue = tbl. Cell(2, 5). Shape.TextFrame.TextRange

    If strName = "" Then strName = "Slide1"
    strDate = oPres.BuiltInDocumentProperties("Last save time")
    strDate = Format(strDate, "mmm dd yyyy hh_mm")
    ' Append cell value to the file name
    oPres.SaveCopyAs Folderpath & "Resaved Files\" & strName & "_" & cellValue & strDate & strSuffix
    oPres.Close
    strFilePath = Dir$
    Wend
    End Sub

    This code retrieves the first table on slide 1 using oPres.Slides(1). Shapes(1). You might need to modify this if you have multiple tables on your slide. The cell value is retrieved using tbl. Cell(2, 5). Shape.TextFrame.TextRange.

    The file name is constructed by concatenating the strName, cell value, strDate, and strSuffix variables. Note that I added an underscore character between strName and cellValue to make the file name more readable.

    I hope this information helps.

    Regards,

    Abdal
  4. bigipi Win User

    Conditional formatting of cells based on a range of given dates

    S P I T ZE

    Jezt muss ich nur versuchen selbst zu begreifen wie es funktioniert :)

    Nochmals vielen, vielen Dank!

    Giorgio
  5. Claus Busch Win User

    Conditional formatting of cells based on a range of given dates

    Hallo,

    wenn du unbedingt englisch schreiben willst, scrolle bitte ganz nach unten und wähle dort Englisch als Sprache. Hier ist das deutsche Forum.

    Markiere deine Zellen D2 bis Ende und gebe bei der bedingten Formatierung als Formel ein:

    =UND($B2<=DATWERT(LINKS(D$1;FINDEN("/";D$1)-1));$C2>=DATWERT(TEIL(D$1;FINDEN("/";D$1)+1;99)))

    und weise dein gewünschtes Format zu.

    Mit freundlichen Grüßen

    Claus
  6. Claus Busch Win User

    Conditional formatting of cells based on a range of given dates

    Hi Giorgio,

    dann probiere es mit:

    =UND($B2<=DATWERT(LINKS(D$1;FINDEN("/";D$1)-1));WENN(UND($B2>0;$C2=0);HEUTE();$C2)>=DATWERT(TEIL(D$1;FINDEN("/";D$1)+1;99)))

    Mit freundlichen Grüßen

    Claus
  7. User Advert


    Hi,

    willkommen im Windows Forum!
Thema:

PPT VBA: Automatically rename saved file based on cell value of a table - Microsoft Office

Die Seite wird geladen...

PPT VBA: Automatically rename saved file based on cell value of a table - Similar Threads - PPT VBA Automatically

Forum Datum

Automatically open a shared file in the app

Automatically open a shared file in the app: Hello, when I send or share a file, e.g., in Word, via "Share" to a person, the other person receives an email with the Word file. However, when I try to open it, it does not open directly in the...
Microsoft Office 4. Juli 2024

EXCEL VBA - Importing and formating a TXT file to a existing table

EXCEL VBA - Importing and formating a TXT file to a existing table: Hey Guys,I'm new to VBA and advanced Excel use. There is a little project I'd like to achieve and maybe some of you are able to help out with some tips :My goal is to extract data out a txt file,...
Microsoft Office 11. Oktober 2023

Sum of unique/distinct values of a filtered column

Sum of unique/distinct values of a filtered column: Hi CommunityI would like to have a cell of the sum of the budget which updates automatically when you set the filter. Here, every market's budget will count only once. In the example below the sum...
Microsoft Office 27. Januar 2023

How to merge cells in a table on a communication site in SharePoint?

How to merge cells in a table on a communication site in SharePoint?: How do I merge cells in an existing table on a communication site in SharePoint? I can't find this option within the tools provided. Is there a work-around?Thank you so much!Best,Nina
Microsoft Office 8. Dezember 2022

Word - Show/Hide table based on checkbox answer

Word - Show/Hide table based on checkbox answer: Greetings,I am trying to show/hide a table, but I am having problems with it. I tried to assign the table a tag and then use it does not work. Anyone has a suggestion on how to do it? I am really...
Microsoft Office 27. Juni 2022

Update Values in Merged Table

Update Values in Merged Table: Hi, I was really trying to find the answer but had no success...I figured out using Power Query to create a merged table from two source tables. There is a unique key in each of the two tables. I...
Microsoft Office 17. Februar 2022

form controlls - combo box cell link returns ralative position instead of cell value

form controlls - combo box cell link returns ralative position instead of cell value: So for example, I have created a list of 12 months January to December (vertical list in different sheet) and I select 01.10.17. The linked cell will not show the selected date (01.10.17) but...
Microsoft Office 15. September 2017
PPT VBA: Automatically rename saved file based on cell value of a table solved
  1. Diese Seite verwendet Cookies, um Inhalte zu personalisieren, diese deiner Erfahrung anzupassen und dich nach der Registrierung angemeldet zu halten.
    Auf dieser Website werden Cookies für die Zugriffsanalyse und Anzeigenmessung verwendet.
    Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies.