Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2017, 01:11 PM
nospamdav999 nospamdav999 is offline Save an excel file with a macro ? Windows 10 Save an excel file with a macro ? Office 2016
Novice
Save an excel file with a macro ?
 
Join Date: Apr 2017
Posts: 4
nospamdav999 is on a distinguished road
Question Save an excel file with a macro ?

Hello everybody,



i have a question, about an excel file, i use a macro to generate files and initially i used to print directly these files, but now i would like to save each file.

My problem, it's working when i use "xlOpenXMLWorkbookMacroEnabled" as the fileformat option, it works like that, but what i would like is to just save the workbook, without the macro, so i have tried with this fileformat "xlOpenXMLWorkbook", but it dosen't work, because i get an error like excel can't save in this format, would you do ...blabla, it's annoying for a macro which should generate the file automatically isn't it ?

Can somebody helps me on this topic ?

I use a workbook, with a table to copy/paste the "variables", and my sheet on the second workbook.

Below i paste my macro :
Code:
Option Explicit    Sub publipostage()  Dim newWst As Worksheet, curCell As Range  Dim File As String  Set curCell = ThisWorkbook.Sheets("Feuil1").Range("A6")    'créer une nouvelle feuille  ThisWorkbook.Worksheets("Feuil4").Copy after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)  Set newWst = ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)  'supprimer le bouton de la feuille  'newWst.Shapes("Rectangle 1").Delete    'boucle sur les entrées de la Feuil1  While curCell.Value <> vbNullString      With newWst          'copier les valeurs          .Range("I8").Value = curCell.Value          .Range("F9").Value = curCell.Offset(0, 2).Value          .Range("R9").Value = curCell.Offset(0, 3).Value          .Range("R8").Value = curCell.Offset(0, 5).Value          .Range("I6").Value = curCell.Offset(0, 9).Value          .Range("P13").Value = curCell.Offset(0, 12).Value          .Range("R6").Value = curCell.Offset(0, 10).Value          .Range("R7").Value = curCell.Offset(0, 11).Value          'impripmer la feuille (printout) ou la sauvegarder (saveas)          On Error Resume Next          '.PrintOut          File = ActiveWorkbook.Path & "\TEST" & curCell.Offset(0, 13).Value & ".xlsm"          'File = "C:\TEST" & curCell.Offset(0, 13).Value & ".xlsm"          .SaveAs Filename:=Fichier, FileFormat:=xlOpenXMLWorkbookMacroEnabled          'Tried with, but dosent works .SaveAs Filename:=Fichier, FileFormat:=51          On Error GoTo 0      End With      Set curCell = curCell.Offset(1, 0)  Wend    'supprime la nouvelle feuille  Application.DisplayAlerts = False  newWst.Delete  Application.DisplayAlerts = True    End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save an excel file with a macro ? Save As PDF Macro/VBA with Predetermined File Name DefinedDesign Word VBA 9 10-29-2014 01:48 PM
Save an excel file with a macro ? Choose file name Save As macro gbaker Excel Programming 28 07-22-2014 03:54 PM
Save an excel file with a macro ? Save As Macro that changes the file name also rosscortb Word VBA 5 05-19-2014 08:40 AM
How do I save a Word file with a macro for distribution? leemoreau Word VBA 3 10-04-2013 08:06 AM
Save an excel file with a macro ? Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft