Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Temperatura AC

Sunt sigure bolurle de plastic (B...

Dimensionare putere centrala / ca...

Impamantare suplimentara
 Scartiei frana fata bicicleta noua

Instalare aer conditionat in apar...

Telefoane prietenoase cu vederea?

Alegere teava pentru incalzire pr...
 Opinia publica despre medici/ asi...

Senzor Temp PMOD-TMP3 cu TCN75A

Amazing Race

Recomandare fosa ecologica
 La multi ani @LouisCyphre!

Vinieta Bulgaria Online

Investitie imobiliara in strainat...

Plita inducție gorenje IC340...
 

Introducere manuala nume fisier in access vba

- - - - -
  • Please log in to reply
10 replies to this topic

#1
adiharan

adiharan

    Oldest member. Probably

  • Grup: Senior Members
  • Posts: 3,724
  • Înscris: 24.03.2002
Am o aplicatie facuta in access din care rezulta un xml, care genereaza niste date.

Dim out_file
    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.CreateTextFile "D:\Dropbox\facturare\2024\factura.xml"
    Set f = fs.GetFile("D:\Dropbox\facturare\2024\factura.xml")
    Set out_file = f.OpenAsTextStream(2, -2)

Aici, imi genereaza automat fisierul "factura.xml". Eu as vrea sa-mi arate un dialog, orice, in care de fiecare data sa scriu eu numele fisierului, nu toate sa fie factura.xml

#2
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,588
  • Înscris: 10.08.2005
Dialogul ala se numeste InputBox
https://learn.micros...putbox-function

https://support.micr...f1-4786575314d9

Edited by MarianG, 19 December 2023 - 18:48.


#3
pasilla

pasilla

    Superior Member

  • Grup: Senior Members
  • Posts: 55,778
  • Înscris: 31.03.2012
Cred ca poti modifica numele si sa fie diferit de fiecare data (in functie de data/ora/parametru)

#4
adiharan

adiharan

    Oldest member. Probably

  • Grup: Senior Members
  • Posts: 3,724
  • Înscris: 24.03.2002
Mersi, asta e clar. Dar nu stiu cum sa trimit variabila mai departe, in fs.CreateTextFile "D:\Dropbox\facturare\2024\factura.xml"

#5
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,588
  • Înscris: 10.08.2005
MyValue = InputBox(Message, Title, Default)
Concatenezi MyValue cu restul locatiei
"D:\Dropbox\facturare\2024\" & MyValue

inainte de concatenare te asiguri ca extensia exista si e cea care trebuie,
sau faci modificari incat sa fie valide

path = "D:\Dropbox\facturare\2024\"
filaname = InputBox();
REM check and clean
full_path = path & filename
fs.CreateTextFile full_path


Edited by MarianG, 19 December 2023 - 19:11.


#6
adiharan

adiharan

    Oldest member. Probably

  • Grup: Senior Members
  • Posts: 3,724
  • Înscris: 24.03.2002
Da, mersi, am reusit. Nu ma inteleg cu concatenarile astea nicicum.
fs.CreateTextFile "D:\Dropbox\facturare\2024\" & MyValue & ".xml"

#7
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,588
  • Înscris: 10.08.2005
looks good

#8
adiharan

adiharan

    Oldest member. Probably

  • Grup: Senior Members
  • Posts: 3,724
  • Înscris: 24.03.2002
Bun, asa merge. Dar am gasit ceva care arata mai bine. Imi deschide fereastra de dialog, dar nu face apoi nimic. Sau gresesc eu ceva? Imi lipsesc oare referinte?

Sub CreateTextFileFromDialog()
    Dim filePath As String
    Dim fileName As String
    Dim fileDialog As Object
    Dim fso As Object
    Dim file As Object
  
    Set fileDialog = Application.fileDialog(3)
    Set fso = CreateObject("Scripting.FileSystemObject")
  
    If fileDialog.show = True Then
    filePath = fileDialog.SelectedItems(1)
    fileName = fso.GetFileName(filePath)
    Set file = fso.CreateTextFile(fileName, True)
    MsgBox fileName
    file.Close
    End If
End Sub

#9
MarianG

MarianG

    be that as it may

  • Grup: Moderators
  • Posts: 31,588
  • Înscris: 10.08.2005
acel dialog doar te ajuta sa creezi fisierul, tot trebuie sa scrii date in el

https://learn.micros...eDialog#remarks

Quote

The msoFileDialogOpen and msoFileDialogSaveAs constants are not supported in Microsoft Access.
Note that when a file is selected using the File open Dialog, the directory containing the selected file will become the current directory for the process. This means that the directory will be locked until the current diectory is changed, or the process terminates. This will prevent the directory from being deleted, moved, or renamed.

Edited by MarianG, 20 December 2023 - 08:00.


#10
adiharan

adiharan

    Oldest member. Probably

  • Grup: Senior Members
  • Posts: 3,724
  • Înscris: 24.03.2002
Da, stiu. Numai ca nu-l creeaza.

#11
adiharan

adiharan

    Oldest member. Probably

  • Grup: Senior Members
  • Posts: 3,724
  • Înscris: 24.03.2002
Asa merge :)

Dim rs
    Dim out_file
    Dim fDialog As filedialog
    Dim filePath As String
    Dim fileName As String
    Dim fso As Object
    Dim file As Object
  
    Set fDialog = Application.filedialog(msoFileDialogSaveAs)
    fDialog.Title = "Save As"
    'fDialog.InitialFileName = "C:\users\adi\desktop\"
    fDialog.Show
  
    If fDialog.SelectedItems.Count > 0 Then
    filePath = fDialog.SelectedItems(1)
    fileName = Right(filePath, Len(filePath) - InStrRev(filePath, "\"))
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.CreateTextFile(fileName & ".xml")
    file.Close
    Set f = fso.GetFile(fileName & ".xml")
    'MsgBox fileName
    Set out_file = f.OpenAsTextStream(2, -2)
    End If

mersi

Anunturi

Chirurgia cranio-cerebrală minim invazivă Chirurgia cranio-cerebrală minim invazivă

Tehnicile minim invazive impun utilizarea unei tehnologii ultramoderne.

Endoscoapele operatorii de diverse tipuri, microscopul operator dedicat, neuronavigația, neuroelectrofiziologia, tehnicile avansate de anestezie, chirurgia cu pacientul treaz reprezintă armamentarium fără de care neurochirurgia prin "gaura cheii" nu ar fi posibilă. Folosind tehnicile de mai sus, tratăm un spectru larg de patologii cranio-cerebrale.

www.neurohope.ro

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate