julienbouchot
Messages postés7Date d'inscriptionjeudi 16 juillet 2009StatutMembreDernière intervention24 juillet 2009
-
20 juil. 2009 à 09:41
julienbouchot
Messages postés7Date d'inscriptionjeudi 16 juillet 2009StatutMembreDernière intervention24 juillet 2009
-
24 juil. 2009 à 05:20
Bonjour,
j'ai actuellement une application VBA Word qui utilise plusieurs fichiers (création, renommage etc) et je ne parviens pas à utiliser les chemins relatifs pour accéder aux dossiers.
julienbouchot
Messages postés7Date d'inscriptionjeudi 16 juillet 2009StatutMembreDernière intervention24 juillet 2009 24 juil. 2009 à 05:14
Bonjour,
activedocument.path ne fonctionne pas non plus...
Je copie colle mon code :
en effet la variable est toujours vide.
Rem MACRO DE PRISE DE REFERENCE CHRONO
Rem Par Philippe BRUNET (POMA-OTIS), 24/05/2000
Rem version visual basic 2000
Rem Version anglaise adaptée POMA BEIJING par Jean-Pierre DURAND (POMA), 07/03/2009
Public Sub MAIN()
Dim titre_dlg$
Dim chrono$
Dim datechrono$
Dim type_chro$
Dim bouton As Integer
Dim emet$
Dim dest$
Dim soc$
Dim noaff$
Dim class$
Dim nomapp$
Dim objet$
Dim fich_type$
Dim fich_nom$
Dim full_path$
Dim cur_path$
Dim annee$
Dim Dlgmistake As Object
Dim h As String
Rem on error Goto mistakes
titre_dlg$ = "V3.0 Chrono ref POMA BEIJING ROPEWAY"
Rem-----------------------DEFINITION DE LA BOITE DE DIALOGUE-------------------------------
Rem-----------------------MAJ et AFFICHAGE DE LA BOITE DE DIALOGUE-------------------------------
Dim Dlgsaisie As Object: Set Dlgsaisie = WordBasic.CurValues.UserDialog
Dlgsaisie.emet$ = WordBasic.[GetBookmark$]("emet")
Dlgsaisie.dest$ = WordBasic.[GetBookmark$]("dest")
Dlgsaisie.soc$ = WordBasic.[GetBookmark$]("soc")
Dlgsaisie.noaff$ = WordBasic.[GetBookmark$]("noaff")
Dlgsaisie.class$ = WordBasic.[GetBookmark$]("class")
Dlgsaisie.nomapp$ = WordBasic.[GetBookmark$]("nomapp")
Dlgsaisie.objet$ = WordBasic.[GetBookmark$]("objet")
chrono$ = WordBasic.[GetBookmark$]("chrono")
datechrono$ = WordBasic.[GetBookmark$]("datechrono")
type_chro$ WordBasic.[GetBookmark$]("type_chro"): If type_chro$ "" Then type_chro$ = "R"
Rem ------------------ RECUPERE LES INFOS DE LA BOITE DE DIALOGUE ------------------------
bouton = WordBasic.Dialog.UserDialog(Dlgsaisie)
emet$ = Dlgsaisie.emet$
dest$ = Dlgsaisie.dest$
soc$ = Dlgsaisie.soc$
noaff$ = Dlgsaisie.noaff$
class$ = Dlgsaisie.class$
nomapp$ = Dlgsaisie.nomapp$
objet$ = Dlgsaisie.objet$
Rem------------PRISE DE LA REFERENCE CHRONO----------------------------------------
'bouton = 0 <=> annuler
'bouton = 1 <=> sans chrono
'bouton = 2 <=> avec chrono (le fax ou le courrier si un seul bouton, ou le fax si 2 choix possibles)
'bouton = 3 <=> avec chrono (le courrier si choix possible entre fax et courrier, sinon, inexistant)
If bouton = 0 Then GoTo fin
If bouton 2 Then type_chro$ "F"
If bouton 3 Then type_chro$ "C"
Rem ----ENREGISTREMENT DU CHRONO DANS UN FICHIER EXCEL----
'Demande confirmation
''Ouverture d'une instance d'excel, avec vérification s'il est déjà ouvert.
cur_path$ = ActiveDocument.Path
annee$ = year(Date)
Dim xlAppList As Excel.Application
Dim xls As Excel.Workbook
Dim ExcelFile
ExcelFile = "U:\Macro FAX\REPORTING\report_bei.xls"
On Error Resume Next
Set xlAppList = GetObject(ExcelFile, "Excel.Application")
If xlAppList Is Nothing Then
Set xlAppList = CreateObject("Excel.Application")
End If
On Error GoTo 0
xlAppList.Visible = True
Set xls = xlAppList.Workbooks.Open(ExcelFile)
Rem Ecriture dans la dernière ligne du tableau.
dercell = Range("A1").End(xlDown).Row + 1
chrono$ = xlAppList.Cells(dercell - 1, 1).Value + 1
xlAppList.Cells(dercell, 1) = chrono$ 'Calcul du chrono
xlAppList.Cells(dercell, 2) = emet$
xlAppList.Cells(dercell, 3) = dest$
xlAppList.Cells(dercell, 4) = soc$
xlAppList.Cells(dercell, 5) = noaff$
xlAppList.Cells(dercell, 6) = class$
xlAppList.Cells(dercell, 7) = nomapp$
xlAppList.Cells(dercell, 8) = objet$
xlAppList.Cells(dercell, 9) = datechrono$
'Sauvegarde et fermeture de l'application
ActiveWorkbook.Save
ActiveWorkbook.Close False
xlAppList.Quit
chrono$ = NumPrefix(CInt(chrono$), 3)
Rem Choix de la feuille à ouvrir en fonction du type de doc. choisi
If type_chro$ = "F" Then
fich_nom$ = "FS_" + annee$ + "_" + chrono$ + "_" + objet$ + ".doc"
full_path$ = cur_path$ + "\FAXS\FAXS_SENT" + fich_nom$
End If
If type_chro$ = "C" Then
Sheets("Courrier").Select
End If
If type_chro$ = "N" Then
Sheets("Notes et CR").Select
End If
'Sauvegarde du document dans le dossier de stockage.
ActiveDocument.SaveAs full_path$
MsgBox ("Votre document est sauvegardé sous le nom : " + fich_nom$)
Rem ----FIN----
Rem #####
Rem-----------DEFINITION DES CHAMPS DE RENVOI DANS LE DOC---------------
majchamps:
Selection.HomeKey Unit:=wdStory
ActiveWindow.View.ShowFieldCodes = True
ActiveDocument.Paragraphs(1).Range.Select
Selection.Delete