Solved

excel automation using vb.net

Posted on 2010-11-15
6
836 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
  • 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:xDJR1875
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

758 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now