+ Reply to Thread
Results 1 to 3 of 3

Column width

  1. #1
    G Lam
    Guest

    Column width

    Hi, I found the following code from the net to email a range of cells in a
    worksheet. It worked with one problem. It would not retain the original
    column width.
    In the Add_range sub, I tried to change

    wsTarget.Range("A1").PasteSpecial (xlPasteAll)
    to
    wsTarge.Range("A1").PasteSpecial (xlPasteColumnWidth)
    but Excel won't take it.
    How can I fix this problem?
    Thank you.
    GL


    *********************************************
    Private Sub CommandButton1_Click()
    If Application.MailSystem <> xlNoMailSystem Then

    With ActiveWorkbook
    Add_range
    ..SendMail Recipients:="[email protected]"
    ..Close SaveChanges:=False
    End With
    Application.MailLogoff
    Else
    MsgBox "No MS-postsystem are installed.", vbInformation, _
    "E-mail message"
    End If
    End Sub
    **********************************************
    Sub Add_range()
    Dim wbOriginal As Workbook
    Dim wsOriginal As Worksheet
    Dim wsTarget As Worksheet
    Dim rnSource As Range

    Set wbOriginal = ThisWorkbook
    Set wsOriginal = wbOriginal.Worksheets("ThisOne")

    With wsOriginal
    Set rnSource = .Range("A1:D10")
    End With

    Application.ScreenUpdating = False

    Workbooks.Add (xlWBATWorksheet)

    Set wsTarget = ActiveSheet

    rnSource.Copy

    wsTarget.Range("A1").PasteSpecial (xlPasteAll)

    With Application
    ..CutCopyMode = False
    ..ScreenUpdating = True
    End With

    End Sub
    ******************************************



  2. #2
    Tom Ogilvy
    Guest

    Re: Column width

    You would need to do both.

    If you are having trouble with ColumnWidth, then see this article.

    http://support.microsoft.com/default...b;en-us;231090

    --
    Regards,
    Tom Ogilvy

    "G Lam" <[email protected]> wrote in message
    news:[email protected]...
    > Hi, I found the following code from the net to email a range of cells in a
    > worksheet. It worked with one problem. It would not retain the original
    > column width.
    > In the Add_range sub, I tried to change
    >
    > wsTarget.Range("A1").PasteSpecial (xlPasteAll)
    > to
    > wsTarge.Range("A1").PasteSpecial (xlPasteColumnWidth)
    > but Excel won't take it.
    > How can I fix this problem?
    > Thank you.
    > GL
    >
    >
    > *********************************************
    > Private Sub CommandButton1_Click()
    > If Application.MailSystem <> xlNoMailSystem Then
    >
    > With ActiveWorkbook
    > Add_range
    > .SendMail Recipients:="[email protected]"
    > .Close SaveChanges:=False
    > End With
    > Application.MailLogoff
    > Else
    > MsgBox "No MS-postsystem are installed.", vbInformation, _
    > "E-mail message"
    > End If
    > End Sub
    > **********************************************
    > Sub Add_range()
    > Dim wbOriginal As Workbook
    > Dim wsOriginal As Worksheet
    > Dim wsTarget As Worksheet
    > Dim rnSource As Range
    >
    > Set wbOriginal = ThisWorkbook
    > Set wsOriginal = wbOriginal.Worksheets("ThisOne")
    >
    > With wsOriginal
    > Set rnSource = .Range("A1:D10")
    > End With
    >
    > Application.ScreenUpdating = False
    >
    > Workbooks.Add (xlWBATWorksheet)
    >
    > Set wsTarget = ActiveSheet
    >
    > rnSource.Copy
    >
    > wsTarget.Range("A1").PasteSpecial (xlPasteAll)
    >
    > With Application
    > .CutCopyMode = False
    > .ScreenUpdating = True
    > End With
    >
    > End Sub
    > ******************************************
    >
    >




  3. #3
    G Lam
    Guest

    Re: Column width

    Tom,
    The link helped.
    paste:= 8 worked perfectly.
    Thank you.
    GL

    "Tom Ogilvy" <[email protected]> ¦b¶l¥ó
    news:OITe%[email protected] ¤¤¼¶¼g...
    > You would need to do both.
    >
    > If you are having trouble with ColumnWidth, then see this article.
    >
    > http://support.microsoft.com/default...b;en-us;231090
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "G Lam" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi, I found the following code from the net to email a range of cells in

    a
    > > worksheet. It worked with one problem. It would not retain the original
    > > column width.
    > > In the Add_range sub, I tried to change
    > >
    > > wsTarget.Range("A1").PasteSpecial (xlPasteAll)
    > > to
    > > wsTarge.Range("A1").PasteSpecial (xlPasteColumnWidth)
    > > but Excel won't take it.
    > > How can I fix this problem?
    > > Thank you.
    > > GL
    > >
    > >
    > > *********************************************
    > > Private Sub CommandButton1_Click()
    > > If Application.MailSystem <> xlNoMailSystem Then
    > >
    > > With ActiveWorkbook
    > > Add_range
    > > .SendMail Recipients:="[email protected]"
    > > .Close SaveChanges:=False
    > > End With
    > > Application.MailLogoff
    > > Else
    > > MsgBox "No MS-postsystem are installed.", vbInformation, _
    > > "E-mail message"
    > > End If
    > > End Sub
    > > **********************************************
    > > Sub Add_range()
    > > Dim wbOriginal As Workbook
    > > Dim wsOriginal As Worksheet
    > > Dim wsTarget As Worksheet
    > > Dim rnSource As Range
    > >
    > > Set wbOriginal = ThisWorkbook
    > > Set wsOriginal = wbOriginal.Worksheets("ThisOne")
    > >
    > > With wsOriginal
    > > Set rnSource = .Range("A1:D10")
    > > End With
    > >
    > > Application.ScreenUpdating = False
    > >
    > > Workbooks.Add (xlWBATWorksheet)
    > >
    > > Set wsTarget = ActiveSheet
    > >
    > > rnSource.Copy
    > >
    > > wsTarget.Range("A1").PasteSpecial (xlPasteAll)
    > >
    > > With Application
    > > .CutCopyMode = False
    > > .ScreenUpdating = True
    > > End With
    > >
    > > End Sub
    > > ******************************************
    > >
    > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1