How to print to file within the same Excel workbook.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deve8ore
    New Member
    • Apr 2008
    • 34

    How to print to file within the same Excel workbook.

    Hello,

    I've already created a dropdown so an end user can pull up a specific file, and this will create a link to a variety of files (.xls, .txt., .pdf, ect...).

    I'd like to set about twenty files within the given folder to transfer to a specific sheet within the same workbook.

    I.e. - One file is "Gross to Net.xls", and once the user selects the dropdown the "Gross to Net.xls" information will be automatically copied and pasted to a sheet (labeled "GTN"). This should happen for all twenty files which will have the same sheet name, so next time the user drops down on another file, different information is populated in each of the 20 sheets.

    So far I can pull up the folder for the user to select the file, but I would like VBA to copy/paste for them:
    [CODE=VB]
    Sub GrossToNet()
    ActiveSheet.Sha pes("AutoShape 109").Select
    Selection.Chara cters.Text = "GrossToNetSumm ary. xls"

    Dim fn As Variant
    ChDrive "T:\"
    ChDir ([GTN])
    fn = Application.Get OpenFilename("A ll files,*.*,XLS Files,*.xls,", _
    1, "Technician Technical Information - Select folder and file to open", , False)
    If TypeName(fn) = "Boolean" Then Exit Sub
    ' the user didn't select a file
    Debug.Print "Selected file: " & fn
    Select Case Right(fn, 3)

    Case Is = "xls"
    ActiveWorkbook. FollowHyperlink Address:=fn
    Case Else
    MsgBox "Please select an Excel file."
    End Select

    Range("a1").Sel ect
    End Sub[/CODE]
    Last edited by Dököll; May 3 '08, 06:13 AM. Reason: [CODE=VB]
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by deve8ore
    Hello,

    I've already created a dropdown so an end user can pull up a specific file, and this will create a link to a variety of files (.xls, .txt., .pdf, ect...).
    ...

    ...

    So far I can pull up the folder for the user to select the file, but I would like VBA to copy/paste for them:

    [CODE=VB]
    Sub GrossToNet()
    ActiveSheet.Sha pes("AutoShape 109").Select
    Selection.Chara cters.Text = "GrossToNetSumm ary. xls"

    Dim fn As Variant
    ChDrive "T:\"
    ChDir ([GTN])
    fn = Application.Get OpenFilename("A ll files,*.*,XLS Files,*.xls,", _
    1, "Technician Technical Information - Select folder and file to open", , False)
    If TypeName(fn) = "Boolean" Then Exit Sub
    ' the user didn't select a file
    Debug.Print "Selected file: " & fn
    Select Case Right(fn, 3)

    Case Is = "xls"
    ActiveWorkbook. FollowHyperlink Address:=fn
    Case Else
    MsgBox "Please select an Excel file."
    End Select

    Range("a1").Sel ect
    End Sub[/CODE]
    Greetings, deve8ore!

    I am not sure how this can be handled, I will however send over to our VBA forum for further support.

    Also, if you have some time, I would fetch through Search box up above, right, perhaps something was already posted on this or something similar:-) Might give you other ideas in the end...

    Good luck with the project:-)

    Dököll
    Last edited by Dököll; May 3 '08, 06:19 AM. Reason: text...

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Most of your posts on this subject have been listed in the Visual Basic forum; are you in fact trying to do this from within an MS Access database?

      Linq ;0)>

      Comment

      Working...