Announcement

Collapse
No announcement yet.

button to create new file

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • button to create new file



    Hello, i could not find the thread i needed and this one is close to what i need.

    I have a Word document and what i want is a macro or a button to create new file...
    1) i want to clear all the contents from the lines
    2) i want to update the numbers of the file and update the date
    3) i want to save the file and create a new file with new name (Daily Log_081-05-09-2019) and when create a new one i want to be new file ( Daily Log_082-06-09-2019) so 81 goes to 82 and 05 goes to 06.
    4) is this possible?

    attached you have a picture with what i want to be erased and what to be updated !!

    Click image for larger version  Name:	image_75344.jpg Views:	0 Size:	72.9 KB ID:	1222850

  • #2
    Hello xlx25,
    Can you please attached the word document ,,the vba syntax for cell and table reference is impossible to work out from a picture.
    If the solution helped please donate to RSPCA

    Sites worth visiting: Rabbitohs | Excel-it royUK | Excel Matters Rory | Kris' Spreadsheet Solutions | Domenic xl-central | The Smallman

    Comment


    • #3
      I would think that Excel would be a better choice for this.
      Hope that Helps

      Roy

      New users should read the Forum Rules before posting

      For free Excel tools & articles visit my web site

      RoyUK's Web Site

      royUK's Database Form

      Where to paste code from the Forum

      About me.

      Comment


      • #4
        Hello,

        see attached the word document.

        Even if will be a master EXCEL sheet for this will be ok, just to export same as this word document !!

        Thank you very much guys !!
        Attached Files

        Comment


        • #5
          Hi ,,
          use this to reset your document
          Code:
          Option Explicit
          Sub ResetTextInCell()
              Dim myCells As Range
              Dim strCellValue As String
              With ActiveDocument.Tables(1)
                  With .Cell(Row:=2, Column:=3).Range
                      strCellValue = Split(.Text, vbCr)(0)
                      If IsNumeric(strCellValue) Then .Text = Format(strCellValue, "#,##0")
                      .Delete
                      .InsertAfter Text:=strCellValue + 1
                  End With
                  With .Cell(Row:=2, Column:=4).Range
                      .Delete
                      .InsertAfter Text:=Format(Now(), "dd-mm-yyyy")
                  End With
              End With
              With ActiveDocument
                  Set myCells = .Range(Start:=.Tables(2).Cell(4, 2).Range.Start, End:=.Tables(2).Range.End)
                  myCells.Delete
              End With
          End Sub
          If the solution helped please donate to RSPCA

          Sites worth visiting: Rabbitohs | Excel-it royUK | Excel Matters Rory | Kris' Spreadsheet Solutions | Domenic xl-central | The Smallman

          Comment


          • #6
            Thank you very much,
            This is only for the word to erase all the contents, i need as well to create a new file on the folder and save as new name...

            Comment


            • #7
              Hello,
              Just add
              Code:
              ActiveDocument.SaveAs2 (ActiveDocument.Path & "\Daily Log " & strCellValue + 1 & " " & Format(Now(), "dd-mm-yyyy") & " XLX25.doc")
              to the end of code
              If the solution helped please donate to RSPCA

              Sites worth visiting: Rabbitohs | Excel-it royUK | Excel Matters Rory | Kris' Spreadsheet Solutions | Domenic xl-central | The Smallman

              Comment


              • #8
                Thank you so much pal.. you are the best !!

                Comment


                • #9


                  No problem, glad it helped
                  If the solution helped please donate to RSPCA

                  Sites worth visiting: Rabbitohs | Excel-it royUK | Excel Matters Rory | Kris' Spreadsheet Solutions | Domenic xl-central | The Smallman

                  Comment

                  Working...
                  X