Solved

excel automation using vb.net

Posted on 2010-11-15
6
874 Views
Last Modified: 2012-06-21
I am getting error which using excel macro in vb.net code
xlWorkSheet.Columns("A:A").Select()
        xlWorkSheet.Selection.Insert(Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove)
        xlWorkSheet.Selection.Insert(Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove)

Open in new window

0
Comment
Question by:CalmSoul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34138111
Take the () off of select maybe? What does the error say? What if you do it like this?
xlWorkSheet.Columns("A:A").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

Open in new window

0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 34138112
What is the error?
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34138118
Actually, do it like this.
xlWorkSheet.Columns("A:A").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
xlWorkSheet.Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

Open in new window

0
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 250 total points
ID: 34138140
Those parameters are the default anyway, you really only need
xlWorkSheet.Columns("A:A").Insert
xlWorkSheet.Columns("A:A").Insert
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 250 total points
ID: 34138182
Just reposting as expert rather than admin comment:


xlWorkSheet.Columns("A:B").Insert(Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove)

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question