/* */

Tuesday, December 14, 2010

Re: [belajar-access] Delete Copy and Paste File




Ma'af tambahan coding :

Function GetPath(Filename As String) As String
GetPath = (Mid(Filename, 1, Len(Filename) - Len(Dir(Filename))))
End Function

Function getfile(Filename As String) As String
'getfile = (Mid(Filename, Len(Filename) - Len(Dir(Filename)) + 1))

'newer, simpler function - go figure
getfile = Dir(Filename)
End Function

regards,

Terima kasih sebelumnya.

regards,



tio.adjie@ptssb.co.id
Sent by: belajar-access@yahoogroups.com

12/14/2010 10:37 AM
Please respond to belajar-access

       
        To:        belajar-access@yahoogroups.com
        cc:        belajar-access@yahoogroups.com
        Subject:        Re: [belajar-access] Delete Copy and Paste File



 


Dear All,


Saya dapatkan di internet , yaitu :


1. Saya buat file template dengan nama file "template.xls" di lokasi file bareng dengan mdb saya.


2. Saya copy template.xls dengan nama "spreadsheet.xls" dan kill spreadsheet.xls (bila sudah ada) di lokasi file sama juga dengan mdb saya, dengan coding sbb. :


Sub exportspreadsheet()

On Error GoTo HandleError

   
Dim objXLApp As Object

Set objXLApp = CreateObject("Excel.Application")

Dim objXLBook As Excel.Workbook


Dim db As DAO.Database


   Set db = CurrentDb

   
   conPath = GetPath(db.Name)

   
   'delete the spreadsheet

   Kill conPath & "spreadsheet.xls"

   
   ' create a workbook from the template

   Set objXLApp = New Excel.Application

   Set objXLBook = objXLApp.Workbooks.Open(conPath & "template.xls")

   'objXLApp.Visible = True


   objXLBook.SaveAs (conPath & "spreadsheet.xls")

   objXLBook.Close


MsgBox "Done!" & vbCrLf & vbCrLf & "Look in the directory" & vbCrLf & vbCrLf & "where the application sits for ""spreadsheet.xls"""


ProcDone:

   On Error Resume Next

   
   ' Let's clean up our act

   Set qdf = Nothing

   Set db = Nothing

   Set rs = Nothing

   Set objResultsSheet = Nothing

   Set objXLBook = Nothing

   Set objXLApp = Nothing


   

   
ExitHere:

   Exit Sub

HandleError:

   Select Case Err.Number

       Case 3265

           Resume Next

       Case 1004

           Set objXLBook = objXLApp.Workbooks.Open(conPath & "Generic.xlt")

           Resume Next

       Case 53

           Resume Next

       Case 75

           Resume Next

       Case Else

           MsgBox Err.Description, vbExclamation, _

            "Error " & Err.Number

   End Select

   Resume ProcDone

End Sub


3. Saya panggil di form. dengan Call exportspreadsheet, dan berhasil..



Tapi saya hanya bisa copy template.xls dengan file spreadsheet.xls dan delete spreadsheet.xls di LOKASI FILE YANG SAMA DENGAN FILE MDB. SAYA.


Pertanyaan saya :


1. Saya mau copy file template.xls dan di pastekan ke folder dengan LOKASI FILE BEDA DENGAN FILE MDB. SAYA.

2. Saya mau copy file template.xls bila file template.xls di LOKASI BEDA DENGAN FILE MDB SAYA.

3. Saya mau delete file template.xls  bila file template.xls di LOKASI BEDA DENGAN FILE MDB SAYA.


Tolong bantuan para suhu Access, adakah yang bisa membantu saya karena saya sudah mencoba merubah coding di atas tapi tidak berhasil juga.


Terima kasih atas jawabannya semoga Tuhan membalas.


Salam Access.


regards,

Tio



tio.adjie@ptssb.co.id
Sent by: belajar-access@yahoogroups.com

12/14/2009 04:57 AM
Please respond to belajar-access

       
       To:        belajar-access@yahoogroups.com

       cc:        

       Subject:        Re: [belajar-access] Delete Copy and Paste File




 


OK mas Aksan, nanti saya buat dulu.

regards,


Aksan Kurdin <aksan.kurdin@gmail.com>
Sent by: belajar-access@yahoogroups.com

04/22/2011 09:30 AM
Please respond to belajar-access

       
      To:        belajar-access@yahoogroups.com

      cc:        

      Subject:        Re: [belajar-access] Delete Copy and Paste File





 

paste = copy + delete

jadi fungsi yang anda butuhkan adalah :
filecopy (source, destination)

dan
kill (source)

untuk menentukan destination bisa gunakan windows dialog, atau office dialog.
bisa ?

coba sekarang giliran tio yang posting hasil kerjanya kesini untuk share sama-sama.
kalau masih bingung, tanya lagi di mana bingung-nya, entar kita kasih cekelan-nya ... :)

aksan kurdin

ps.
hati-hati dengan fungsi kill, tidak bisa restore lagi file yang di kill, tidak ada di recycle bin.

On 4/21/2011 1:38 PM,
tio.adjie@ptssb.co.id wrote:
 


Salam Access,


Selamat siang teman-teman.


Mohon bantuannya, adakah diantara teman-teman yang punya coding untuk mendelete , copy dan mempaste (memindahkan) file , seperti File Excel dengan lokasi yang ditentukan user ?


Terima kasih semoga Allah membalas kebaikan teman-teman.


Salam.






__._,_.___


SPAM IS PROHIBITED



Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

No comments:

Post a Comment