Consulting

Results 1 to 9 of 9

Thread: Solved: Workbook

  1. #1

    Solved: Workbook

    Hi,

    Please check the code in the attached file. I am trying to create a new workbook and copying entire content of sheet1 to new workbook.

    Thanks in advance.

    Regards,

    Chandra Shekar

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim fnm
    fnm = Application.GetSaveAsFilename("", "Excel Files (*.xls), *.xls")
    If IsNull(fnm) = True Then
    MsgBox "File Name is Blank"
    Else
    Sheets("Sheet1").Copy
    ActiveWorkbook.SaveAs fnm
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Hi,

    Thank you its working.

    Regards,

    Chandra Shekar

  4. #4
    Hi,

    How to check if file exists are not. If exists code should give error message that file already exists.

    Thanks

    Chandra Shekar

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Exists, or is open?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Hi,

    I need code for both the option please.

    Thanks

    Chandra Shekar

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub DoubleCheck()
    Const FILE_PATH As String = "C:\some directory\"
    Const FILE_NAME As String = "somefile.xls"
    Dim filename As String

    filename = Dir(FILE_PATH & FILE_NAME, vbNormal)
    If filename = "" Then

    MsgBox FILE_PATH & FILE_NAME & " does not exist"
    Else

    If Not CBool(Workbooks(FILE_NAME) Is Nothing) Then

    MsgBox FILE_NAME & " already open"
    End If
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Hi,

    How to apply this code with the previous code. Please let me know. I am new to VBA.

    Thank you

    Chandra Shekar

  9. #9
    Hi,

    Any suggestion xld.

    Thanks
    Chandra Shekar

Posting Permissions

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