Quick Search


Tibetan singing bowl music,sound healing, remove negative energy.

528hz solfreggio music -  Attract Wealth and Abundance, Manifest Money and Increase Luck



 
Your forum announcement here!

  Free Advertising Forums | Free Advertising Board | Post Free Ads Forum | Free Advertising Forums Directory | Best Free Advertising Methods | Advertising Forums > Post Your Free Ads Here in English for Advertising .Adult and gambling websites NOT accepted. > Post Your Products & Services Here

Post Your Products & Services Here This section is for posting your free classified ads about new products and services, software, ebooks, and more.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 08-01-2011, 04:42 PM   #1
daaskood7317
 
Posts: n/a
Default office 2007 Enterprise product key Manually paste

Recently, I had a bunch of cool PowerPoint 2010 templates that I wanted to publish. A colleague was going to take each template and a short paragraph describing the template and create the downloadable files. So I saved the PowerPoint templates (.potx) to a network file share and then created a matching text file (.txt) for each template with a description in the same folder.

Shortly afterward, my colleague asked me if I had any descriptions for the templates. "Yes," I say, "they're included in that shared folder with the templates. I saved each description as a text file."

Nonplussed, my colleague asks, "Um,Windows 7 Home Premium 64, could you put all of the descriptions into a single Excel workbook?"

Sigh.

So here's my problem. I needed to turn this:



... into this:



Altogether, the folder had approximately 40 text (.txt) files that I needed to compile into the workbook, where the content would be listed out row by row on a single worksheet. From left to right, each row needed to include my name, the file name of the PowerPoint template, the template's title (the file name cleaned up a bit),Windows Product Key, and the 255 character description.

Certainly, I could have typed the filename into the second column, wrote a formula in the third column to translate the filename into a title, and then copied and pasted from the text file into the workbook. Or,Windows 7 Enterprise X86, if had been so inclined, I could have just used the From Text command in the Get External Data group on the Data tab.

Spend that kind of time creating a workbook? Pshaw,office 2007 Enterprise product key!

Instead, I wrote some Visual Basic code to pull the data that I need from the folder with the PowerPoint and text files and then enter it into the workbook.

To get the text from the .txt files into the Excel workbook, the code uses the Directory.GetFiles method and a search pattern to open only the text files in the specified folder. It enters the name of the text file to the next blank row in column B of the active sheet. Then the code opens each text file with a StreamReader object and appends each line of text from the file to a string variable. Once each line of text in the file has been written to the string, the string is added to column D in the same row. Then the row counter is incremented to move to the next row and the process repeats until it has transcribed each .txt. file in the specified folder.

Here's the code that I used. It is a workbook-level project using Visual Studio 2010, Visual Basic, .NET 4, and Excel 2010.

Imports Microsoft.VisualBasic.FileIO

Imports System.IO

Imports System


Public Class ThisWorkbook


Private Sub ThisWorkbook_Open() Handles Me.Open


' Create an array where each item is a text file in the folder

Dim MyFiles As String() = Directory.GetFiles("C:\My Documents\ImportText_TEST", "*.txt")

Dim MyFile As String


Dim MyWorkbook As Excel.Workbook = Me.Application.ActiveWorkbook

Dim MySheet As Excel.Worksheet = Me.Application.ActiveSheet


' Set up header rows

With MySheet

.Range("A5").Value = "Office.com contact"

.Range("B5").Value = "File Name"

.Range("C5").Value = "Template Title"

.Range("D5").Value = "Description"

End With


' Create a counter for workbook rows

Dim numline As Integer = 6


For Each MyFile In MyFiles


' Create a StreamReader object

Dim MyReader As StreamReader = New StreamReader(MyFile)


Dim currLine As String

Dim currCellValue As String = ""


' MyFileName string includes directory

' The file name of text file begins at character 32

' Enter file name and template name into spreadsheet

With MySheet

.Range("A" & numline).Value = "Eric Schmidt"

.Range("B" & numline).Value = _

MyFile.Substring(32).Replace(".txt",Office 2010 Home And Business Key, ".potx")

.Range("C" & numline).Value = _

MyFile.Substring(32).Replace("_", " ").Replace(".txt", "")

End With


Do

' Read each line that contains text and add to currCellValue string

currLine = MyReader.ReadLine()


currCellValue = currCellValue + " " + currLine


Loop Until currLine Is Nothing


' Close the text file

MyReader.Close()


' Enter currCellValue into the spreadsheet

With MySheet.Range("D" & numline)

.Value = currCellValue

.WrapText = True

End With


numline = numline + 1


Next


' Resize the rows and columns in the workbook

With MySheet

.Columns("D").ColumnWidth = 75

.Range(.Cells(1, 1), _

.Cells(numline, 4)).Rows.AutoFit()

.Range("A:D").Columns.AutoFit()

End With

End Sub

End Class

To write this code, I consulted the following articles:
The Directory.GetFiles method Reading Text from a File The Range.Autofit method
--Eric Schmidt

Eric Schmidt is a programming writer for Visio.
<div
  Reply With Quote
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 12:12 PM.

 

Powered by vBulletin Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Free Advertising Forums | Free Advertising Message Boards | Post Free Ads Forum