Excel vba

574 palavras 3 páginas
Control Excel from Word using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Applications - Word, Outlook in VBA VERSION - All Microsoft Excel Versions
The two example macros below demonstrates how you can send information to Excel from Word
(e.g. creating a new workbook) and how you can retrieve information from Excel (e.g. reading information from a workbook).
Note! Read and edit the example code before you try to execute it in your own project! Sub CreateNewExcelWB() ' to test this code, paste it into a Word module ' add a reference to the Excel-library ' create a new folder named C:\Foldername or edit the filnames in the code Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Dim i As Integer Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set xlWB = xlApp.Workbooks.Add ' create a new workbook ' or 'Set xlWB = xlApp.Workbooks.Open("C:\Foldername\Filename.xls") ' open an existing workbook ' example excel operations With xlWB.Worksheets(1) For i = 1 To 100 .Cells(i, 1).Formula = "Here is a example test line #" & i Next i If Dir("C:\Foldername\MyNewExcelWB.xls") <> "" Then Kill "C:\Foldername\MyNewExcelWB.xls" End If .SaveAs ("C:\Foldername\MyNewExcelWB.xls") End With xlWB.Close False ' close the workbook without saving xlApp.Quit ' close the Excel

Relacionados

  • Vba - excel
    4167 palavras | 17 páginas
  • VBA Excel
    11396 palavras | 46 páginas
  • Vba no excel
    2347 palavras | 10 páginas
  • Vba para excel
    2356 palavras | 10 páginas
  • excel vba
    499 palavras | 2 páginas
  • excel VBA
    11569 palavras | 47 páginas
  • Excel VBA
    12337 palavras | 50 páginas
  • VBA excel
    582 palavras | 3 páginas
  • VBA excel
    4535 palavras | 19 páginas
  • vba excel
    1186 palavras | 5 páginas