Author Topic: EXcel macro  (Read 5906 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
EXcel macro
« on: February 22, 2013, 01:09:18 PM »
I don't if this is a proper thread for this forum.

If so, I need to export multiple cells ( all strings ) in a 2013 excel spreadsheet to pre determined file name in true ASCII text, overwriting the entire file if it exists.

Could some one give me a push in the right direction? 

Thanks!  -David

ie cells ct3 thru ct29 AND dt3 thru dt26   to   c:/acad/proj.dat
R12 Dos - A2K

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: EXcel macro
« Reply #1 on: February 22, 2013, 01:27:30 PM »
The simples way would be to link the cells to another worksheet then create a macro (you could use the macro recorder for this) to export the linked cells to your proj.dat file.

http://smallbusiness.chron.com/multiple-cells-excel-another-worksheet-35868.html
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #2 on: February 22, 2013, 01:34:40 PM »
Thanks! I'm looking into it.  I've used very old MS spreadsheets for add formulas to.  I'll try the learning curve here.  It seems to be worth it.  I'll probably ask more newbie questions.  thanks  again!  _David
R12 Dos - A2K

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: EXcel macro
« Reply #3 on: February 22, 2013, 01:39:45 PM »
What is the output format? If comma delimited is ok, just save it as a CSV file ...

Saving the data to a file is relatively simple, but you must know what format you want .. simple ascii isn't specific enough ... do you need the contents one item on each line or all on one line. Are you using spaces between the data?

Number 5 needs more input
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #4 on: February 22, 2013, 01:49:03 PM »
OK I got a new worksheet linked and the data is there.

Ouput file:

1 line per cell
there may be spaces in the data, but the program reading the data can compensate
no blank lines

ie
type1:electric
type2:right
type3:na
name1:me
anme2:you

R12 Dos - A2K

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #5 on: February 22, 2013, 01:56:34 PM »
So now I have

sheet4
cells a1:a50

Now I have to find the macro reorder.  You'd think that would a prominent button a ribbon  ( I hate ribbons )
R12 Dos - A2K

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: EXcel macro
« Reply #6 on: February 22, 2013, 02:22:31 PM »
You have to right-click on ribbon and select customize.  Then toggle on the developer tab.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #7 on: February 22, 2013, 02:42:04 PM »
Found it !


Know learning how it works.  I would personnlay rather write the code than use a recorder.  But that's a long way off.

-David
R12 Dos - A2K

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: EXcel macro
« Reply #8 on: February 22, 2013, 03:03:01 PM »
Found it !


Know learning how it works.  I would personnlay rather write the code than use a recorder.  But that's a long way off.

-David
The recorder will get you started.  :)
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #9 on: February 22, 2013, 03:10:08 PM »
So far so good

Code: [Select]
Sub Macro5()
'
' Macro5 Macro
'
' Keyboard Shortcut: Ctrl+k
'
    Sheets("Sheet4").Select
    Application.Goto Reference:="R1C1"
    Range("A1:A50").Select
    ActiveWorkbook.SaveAs Filename:="C:\acad\proj.txt", FileFormat:= _
        xlTextMSDOS, CreateBackup:=False
    Sheets("Sheet1").Select
End Sub

How to prevent the over write dialog boxes from coming up ?

Thanks!  -David
R12 Dos - A2K

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: EXcel macro
« Reply #10 on: February 22, 2013, 03:14:28 PM »
I believe this will prevent the overwrite dialog box from showing up.


Code: [Select]
Application.DisplayAlerts = False
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #11 on: February 22, 2013, 03:20:43 PM »
I believe this will prevent the overwrite dialog box from showing up.


Code: [Select]
Application.DisplayAlerts = False

Yep  it DID!

Getting very close to what I need  Tthanks!  -David
R12 Dos - A2K

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #12 on: February 22, 2013, 04:13:54 PM »
Okay,  the thing that I don't like now is when you go back to sheet1, the saveas command goes to a dos txt file type not a xlsm file type that it needs,.  Any ideas?  -David
R12 Dos - A2K

David Bethel

  • Swamp Rat
  • Posts: 656
Re: EXcel macro
« Reply #13 on: February 23, 2013, 02:40:54 PM »
OK  I I've searched pretty hard now.

Is there a decent 'Function Reference' site for excel macros.  Microsoft vacuums when it comes to help or reference materials.

At least AutoLISP has some human readable sites.  thanks -David
R12 Dos - A2K