2017-03-02 2 views
0

"Create invoice"ボタンを使用してAccessでフォームを作成したいとします。私は次のようにしてみます:VBAインボイス作成でアクセス入力フォームでExcel

  • Excelの「請求書テンプレート」をコピーしてください。

  • 「テンプレート」フォルダから「請求書テンプレート」フォルダを「請求書」フォルダに移動します。

  • 「請求書送信レジスタ」(Excelファイル)を開きます。

  • "customer adresses register"(Excelファイル)を開きます。

  • 請求書テンプレートコピーの名前を、テキストボックスに入力できるものの名​​前に変更します。

  • 秒を待ちます。

  • 新しく作成したExcelファイルを開いて、Excelでテンプレートを入力します。

これは私が思い付いたコードは次のとおりです。

Private Sub Knop1_Click() 

    'Open register with customer adresses 
    Dim xlApp As Object 
    Set xlApp = CreateObject("Excel.Application") 
    xlApp.Visible = True 
    xlApp.Workbooks.Open "\\WDMyCloudEX4\Zakelijk\Documenten\Betalingen\Faktuur adressen.xlsx", True, False 
    Set xlApp = Nothing 

    'Open folder with invoices 
    Call Shell("explorer.exe" & " " & "\\WDMyCloudEX4\Zakelijk\Documenten\SFMT\Afleveringsbonnen 2008-heden\2017\Nieuwe systeem (1-3-2017)", vbNormalFocus) 

    'Make a copy of the invoice template 
    FileCopy "\\WDMyCloudEX4\Zakelijk\Documenten\SFMT\Afleveringsbon.xlsx", "\\WDMyCloudEX4\Zakelijk\Documenten\SFMT\Afleveringsbonnen 2008-heden\2017\Nieuwe systeem (1-3-2017)\Nieuwe afleveringsbon.xlsx" 

    'Define to what the invoice template should be renamed 
    Year = [Tekst3] 
    Month = [Tekst6] 
    Count = [Tekst9] 
    NEWNAME = Year + Month + Count 

    'Move and rename the invoice template copy 
    Name "\\WDMyCloudEX4\Zakelijk\Documenten\SFMT\Afleveringsbonnen 2008-heden\2017\Nieuwe systeem (1-3-2017)\Nieuwe afleveringsbon.xlsx" As "\\WDMyCloudEX4\Zakelijk\Documenten\SFMT\Afleveringsbonnen 2008-heden\2017\Nieuwe systeem (1-3-2017)\P95+$NEWNAME.xlsx" 

    'Wait a second to make sure the copiing is completed 
    Sleep (1000) 

    'Open the moved and renamed invoice template copy 
    Dim xlApp As Object 
    Set xlApp = CreateObject("Excel.Application") 
    xlApp.Visible = True 
    xlApp.Workbooks.Open "\\WDMyCloudEX4\Zakelijk\Documenten\SFMT\Afleveringsbonnen 2008-heden\2017\Nieuwe systeem (1-3-2017)\P95+telling", True, False 
    Set xlApp = Nothing 

End Sub 

すべてのヘルプは、これは私が今時間しようとしている...狂気私を運転している、非常に歓迎されるであろう。

+0

上記のコードのどの部分に問題がありますか? –

答えて

0
あなたは、実際の問題が何であるかを明記していないが、私は、問題の少なくとも一部は、このコードであることを前提としてい

:このコードで

'Open register with customer adresses 
Dim xlApp As Object 
Set xlApp = CreateObject("Excel.Application") 
xlApp.Visible = True 
xlApp.Workbooks.Open "\\WDMyCloudEX4\Zakelijk\Documenten\Betalingen\Faktuur adressen.xlsx", True, False 
Set xlApp = Nothing 

あなたはExcelアプリケーションオブジェクトを作成し、Excelブックを開いていますブックを開いた直後にすぐにアプリケーションオブジェクトを破棄することができます。したがって、効果的にブックを開いてすぐに閉じることができます。

関連する問題