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
Solved

excel automation using vb.net

Posted on 2010-11-15
6
858 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: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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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 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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

856 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