Importation de données asc / perte du format à l'enregistrement

calire2009 Messages postés 2 Date d'inscription mercredi 11 février 2009 Statut Membre Dernière intervention 13 février 2009 - 11 févr. 2009 à 18:00
calire2009 Messages postés 2 Date d'inscription mercredi 11 février 2009 Statut Membre Dernière intervention 13 février 2009 - 13 févr. 2009 à 10:14
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ProgId" content="Word.Document" />
<meta name="Generator" content="Microsoft Word 11" />
<meta name="Originator" content="Microsoft Word 11" />
<link rel="File-List" href="file:///C:%5CDOKUME%7E1%5Cclaire%5CLOKALE%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Normale Tabelle";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->

Bien le bonsoir à tous !








Je me mets aux
macros sous excel depuis peu.








 








J’ai créé une
macro pour importer un fichier .asc depuis excel, y faire quelques analyses (j’appelle une
autre macro), puis l’enregistrer au format .xls












Le problème c'est qu'en fermant le fichier, excel me dit qu'il ne peut enregistrer le fichier que sous un format de base, du genre txt, ce qui fait que je perds des info importantes, en particulier les formules que j'utilise.











Je ne sais pas si le problème vient de l'importation du fichier asc, de l'enregistrement sous xls...












quelqu'un peut-il m'aider/me conseiller ?



merci d'avance !



Calire












ci dessous le code que j'utilise sous visual basic :
























Sub TraiteLeFichier100R()
'''ouvrir fichier .asc
    Workbooks.OpenText Filename:= _
        "C:\Dokumente und Einstellungen\expe1-1-1\100R.asc" _
        , Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
        :=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _
        False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array _
        (1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), _
        TrailingMinusNumbers:=True
       
'''appeler macro de traitement des données
Call MacroPREPARATIONbis
   
'''sauver le fichier


    ActiveWorkbook.SaveAs Filename:= _
        "C:\Dokumente und Einstellungen\expe1-1-1\100R.xls" _
        , FileFormat:=xlText, CreateBackup:=False
    ActiveWorkbook.Save

'''fermer
    ActiveWindow.Close
End Sub








ps: je suis pas du tout sure du thème de mon topic...



                                                                           --------
                                                                              

2 réponses

cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
11 févr. 2009 à 20:15
Salut
Oui, Excel est du VBA, pas tout à fait du VB6 --> Modif catégorie.

Normal : Tu sauves un XLS au format TEXT :
   ActiveWorkbook.SaveAs Filename:= _
        "C:\Dokumente und Einstellungen\expe1-1-1\100R.xls" _        , FileFormat:xlText , CreateBackup:False

Utilise xlNormal
Quand tu as un doute, enregistre une macro pendant que tu fais la manip à la main et regarde le code.
C'est comme ça que j'ai fait pour trouver ton erreur.

Vala
Jack, MVP VB
NB : Je ne répondrai pas aux messages privés

<hr />Le savoir est la seule matière qui s'accroit quand on la partage (Socrate)
0
calire2009 Messages postés 2 Date d'inscription mercredi 11 février 2009 Statut Membre Dernière intervention 13 février 2009
13 févr. 2009 à 10:14
ca marche, cool merki !

                          ----------
                              
0
Rejoignez-nous