?
Solved

excel automation using vb.net

Posted on 2010-11-15
6
Medium Priority
?
887 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 1000 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 1000 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

Industry Leaders: 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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

800 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