Office Programming Idea (VBA)

xiaoxiao2021-03-06  64

Below is the code of VB Open file: if Dir ("D: /Excel.bz") = "" "" "" t 'Judging whether EXCEL opens set xlapp = createObject ("excel.application")' Create an Excel application class XLapp.visible = true 'Setting Excel visible set xlbook = xlapp.workbooks.open ("d: /test.xls")' Open Excel workbook set xlsheet = xlbook.worksheets (1) 'Open Excel worksheet ActiveWorkbook.save xlapp.displayAlerts = false xlapp .Screenupdating = true xlapp.quit

The END IF then opens the Excel worksheet, doing the operations prepared by doing the program on the worksheet and records "macro", copy directly to the blank place above. Just get it. The macro code is as follows (VBA code, where a small number of code is modified according to the VBA programming syntax): 'The following information comes from the macro RANGE ("A4: C4"). SELECT Selection.copy Range ("a11"). Select Activeesheet.Paste Range ("A3: C3"). Select Application.cutcopyMode = false Selection.copy Range ("a4"). Select activesheet.paste Range ("A5"). Select Activeesheet.Paste Range ("A6"). Select Activeesheet.Paste Range ("a7"). Select activesheet.paste Range ("a8"). Select activesheet.paste Range ("a9"). Select activesheet.Paste Range ("a10"). Select Activesheet.Paste Application.cutcopyMode = False for i = 1 to 9 Range ("a" & (i 1)). Select activecell.formular1c1 = "item" & i range ("b" & (i 1)). Select activecell.formular1c1 = i = rge C "& (i 1)). Select activecell.formular1c1 =" Description "& I next Range). Select activecell.formular1c1 =" = SUM (r [-9] C: r [-1] c "That is very similar to Word, other languages ​​(such as C ) can be made in this grammatical structure COM programming

转载请注明原文地址:https://www.9cbs.com/read-85451.html

New Post(0)