Francois73
XLDnaute Occasionnel
Bonjour à toutes et à tous
j'ai bientôt terminé mon fichier, il me reste à exporter une feuille en txt , le code ci dessous fonctionne
mais je voudrais choisir l'emplacement de l'enregistrement du txt. par defaut il le met dans "mes documents" et je souhaiterai que le fichier txt soit enregistrer à côté du fichier excel soit dans le dossier ouvert .
voici le code
merci pour votre aide
Sub feuiltxt()
Dim wb As Workbook, ws As Worksheet
Dim newWB As Workbook, newWS As Worksheet
Dim strSaveAs As String
On Error GoTo errSave
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Set ws = ActiveSheet
With ws
.Select
.Copy
End With
Set newWB = ActiveWorkbook
Set newWS = ActiveSheet
strSaveAs = InputBox("Please enter filename.")
With newWB
.SaveAs strSaveAs, xlText
.Close (False)
End With
wb.Activate
ws.Select
exitSave:
Application.ScreenUpdating = True
Exit Sub
errSave:
MsgBox (Err.Number)
MsgBox (Err.Description)
Resume exitSave
End Sub
j'ai bientôt terminé mon fichier, il me reste à exporter une feuille en txt , le code ci dessous fonctionne
mais je voudrais choisir l'emplacement de l'enregistrement du txt. par defaut il le met dans "mes documents" et je souhaiterai que le fichier txt soit enregistrer à côté du fichier excel soit dans le dossier ouvert .
voici le code
merci pour votre aide
Sub feuiltxt()
Dim wb As Workbook, ws As Worksheet
Dim newWB As Workbook, newWS As Worksheet
Dim strSaveAs As String
On Error GoTo errSave
Application.ScreenUpdating = False
Set wb = ActiveWorkbook
Set ws = ActiveSheet
With ws
.Select
.Copy
End With
Set newWB = ActiveWorkbook
Set newWS = ActiveSheet
strSaveAs = InputBox("Please enter filename.")
With newWB
.SaveAs strSaveAs, xlText
.Close (False)
End With
wb.Activate
ws.Select
exitSave:
Application.ScreenUpdating = True
Exit Sub
errSave:
MsgBox (Err.Number)
MsgBox (Err.Description)
Resume exitSave
End Sub