Showing posts with label multiple. Show all posts
Showing posts with label multiple. Show all posts

How to replace text in multiple blocks of DWG files with Excel VBA Macro using NanoCAD Free/AutoCAD.

If your DWG files use blocks for the similar information such as Dates, titles, etc. and these text are placed in multiple places in your drawings, you can automate replacing their text content from the template DWG file to edition DWG file state. If your project DWG files contents 50-100, etc. blocks, manual text replace will take some time. Simply create one template DWG file once and next time change data you need to replace fast in our Excel file with Macro.
For quick text replacement in multiple blocks of DWG files use free version of NanoCAD or AutoCAD commercial software.




Use NanoCAD Free:
1. Download NanoCAD Free
http://nanocad.com/page/DownloadNanoCAD
2. Read official NanoCAD installation guide
http://nanocad.com/page/InstallationGuide
In PDF format
http://nanocad.com/images/InstallGuide/InstallGuide.pdf
Use video guide
http://nanocad.com/page/InstallationVideo
3. Don’t forget to register and activate NanoCAD Free.
4. Download “Replace_Text_In_Blocks_Excel_NanoCAD.xlsm” Excel file with Macro.
5. Open Excel file, press “ALT+F11” to open Microsoft Visual Basic for Application, then “Tools - References”, add:
“nanoCAD Type Library (NCAuto.dll)”
“OdaX Type Library (OdaX_csd.dll)”,
then press OK.




6. Close Microsoft Visual Basic for Application editor.
7. Enable Macros in Excel
https://support.office.com/en-us/article/Enable-or-disable-macros-in-Office-documents-7b4fdd2e-174f-47e2-9611-9efe4f860b12
8. Copy all DWG files to the same folder with Excel file. In these DWG files NanoCAD will replace Text according to Data Table of “Replace_Text_In_Blocks_Excel_NanoCAD.xlsm” Excel file.
9. Press “ALT+F8” to run “Replace_Text_In_Blocks_Excel_NanoCAD” macro.
10. Macro will open NanoCAD application and replace all text in DWG blocks and close DWG files

Use AutoCAD commercial version:
1. Download “Replace_Text_In_Blocks_Excel_AutoCAD.xlsm” Excel file with Macro.
2. Open Excel file, press “ALT+F11” to open Microsoft Visual Basic for Application, then “Tools - References”, add:
“AutoCAD YYYY Type Library” file” (acaxXXenu.tlb),
where YYYY – YEAR of your AutoCAD Version, XX – 21, 20, 19,…(version number);
“AutoCAD Focus Control for VBA Type Library” (AcFocusCtrlXX.dll);
“AXDBLib” (axdbXXenu.tlb),
then press OK.


3. Close Microsoft Visual Basic for Application editor.
4. Enable Macros in Excel
https://support.office.com/en-us/article/Enable-or-disable-macros-in-Office-documents-7b4fdd2e-174f-47e2-9611-9efe4f860b12
5 Copy all DWG files to the same folder with Excel file. In these DWG files AutoCAD will replace Text according to Data Table of “Replace_Text_In_Blocks_Excel_AutoCAD.xlsm” Excel file.
6. Press “ALT+F8” to run “Replace_Text_In_Blocks_Excel_AutoCAD” macro.
7. Macro will open AutoCAD application and replace all text in DWG blocks and close DWG files

Known features and limitations:
a. Maximum DWG files – 1000.
b. Maximum different blocks quantity to change/insert text - 65530.
c. “Block Name” cell must contain DWG block name (for example, DATASHEET_TITLE, DATE, DESCRIPTION for “Stepping Motor SH4009l1206 Blocks.dwg” file in ZIP archive). “Block Name” could be A$C26677C24, etc.
d. “Data Type” cell could be: “FullText” or “InternalText”.
For «FullText» Type macro will replace text in blocks which consists of Text/MText DWG objects.
For “InternalText” Type macro will replace text between “Text Before Insert” and “Text After Insert” words in blocks with Text. If you clear “Block Name” cell for “InternalText” Type row macro will insert text in all Text/MText objects that are not in blocks.
e. “Value To Replace/Insert” cell must contains text to replace/insert in blocks or Text/MText DWG objects.
f. “Font Height” cell data will change Text Height where macro replaces the text. Cell format for Font height is a Number with decimal separator according to Excel/System settings.
https://support.office.com/en-us/article/Change-the-character-used-to-separate-thousands-or-decimals-c093b545-71cb-4903-b205-aebb9837bd1e

How to extract tables of lines, polylines and Text, MText from DWG files to Excel with NanoCAD Free/AutoCAD

For all tables and datasheets which were made as tables of lines, polylines and Text, MText in DWG files you need to manually copy from Text, MText blocks and paste their content to Excel to use data from them. This long process could be automated with Excel file with Macro to create tables of lines, polylines and Text, MText from DWG files to Excel sheets.

There are two options to extract tables of lines, polylines and Text, MText: use free version of NanoCAD or AutoCAD commercial software.

Use NanoCAD Free:
1. Download NanoCAD Free
2. Read official NanoCAD installation guide
http://nanocad.com/page/InstallationGuide
In PDF format
Use video guide
3. Don’t forget to register and activate NanoCAD Free.
4. Download “Extract_Line_Tables_from_DWG_to_Excel_NanoCAD.xlsm” Excel file with Macro.
5. Open Excel file, press “ALT+F11” to open Microsoft Visual Basic for Application, then “Tools - References”, add:
“nanoCAD Type Library (NCAuto.dll)”
“OdaX Type Library (OdaX_csd.dll)”,
then press OK.


6. Close Microsoft Visual Basic for Application editor.
7. Enable Macros in Excel
https://support.office.com/en-us/article/Enable-or-disable-macros-in-Office-documents-7b4fdd2e-174f-47e2-9611-9efe4f860b12
8. Copy all DWG files to the same folder with Excel file. From these DWG file all tables of lines, polylines and Text, MText will are created on Excel sheets.
9. Press “ALT+F8” to run “Extract_Line_Tables_from_DWG_To_Excel_NanoCAD” macro.
10. Macro will open NanoCAD application and scan all tables of lines, polylines and Text, MText in DWG files. Each created table from DWG file will be placed on a new Excel sheet.

Use AutoCAD commercial version:
1. Download “Extract_Line_Tables_from_DWG_to_Excel_AutoCAD.xlsm” Excel file with Macro.
2. Open Excel file, press “ALT+F11” to open Microsoft Visual Basic for Application, then “Tools - References”, add:
“AutoCAD YYYY Type Library” file” (acaxXXenu.tlb),
where YYYY – YEAR of your AutoCAD Version, XX – 21, 20, 19,…(version number);
“AutoCAD Focus Control for VBA Type Library” (AcFocusCtrlXX.dll);
“AXDBLib” (axdbXXenu.tlb),
then press OK.

3. Close Microsoft Visual Basic for Application editor.
4. Enable Macros in Excel
https://support.office.com/en-us/article/Enable-or-disable-macros-in-Office-documents-7b4fdd2e-174f-47e2-9611-9efe4f860b12
5 Copy all DWG files to the same folder with Excel file. From these DWG file all tables of lines, polylines and Text, MText will are created on Excel sheets.
6. Press “ALT+F8” to run “Extract_Line_Tables_from_DWG_To_Excel_AutoCAD” macro.
7. Macro will open AutoCAD application and and scan all tables of lines, polylines and Text, MText in DWG files. Each created table from DWG file will be placed on a new Excel sheet

Known features and limitations:
a. Maximum DWG files – 1000.
b. There are no limitations for table’s quantity for each DWG file or each layout.
c. Each table contour (outline) must be closed.
d. Each cell must be rectangular, not use “stairs” like cells.
e. All text found in the DWG table cell will are placed in Excel cell by vertical order from top to bottom.
f. Tables in DWG files must be draw with lines, old type polylines (2D polylines), Text and MText basic primitives.
e. If your DWG tables are made of blocks with lines, polylines, please explode them all before running the Macro.
f. If your DWG text are made of blocks with Text, MText, please explode them all before running the Macro also.
g. “Extract_Line_Tables_from_DWG_To_Excel” Macro supports creating merged cells found in DWG files.
h. Macro will extract data even there are no some additional SHX fonts installed for DWG file and the text in NanoCAD Free/AutoCAD is shown as “?????????”.
i. All text from DWG files will be copied as “Text” with “Format Cells”
j. All Fonts formatting – Bold, Italic, etc. will be unformatted according to these specifications:
https://knowledge.autodesk.com/support/autocad/getting-started/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-7D8BB40F-5C4E-4AE5-BD75-9ED7112E5967-htm.html

How to split Excel book with multiple sheets to single files

This guide shows how to split Excel workbook with multiple sheets into single files. For most compatibility, for ".xls" files (Excel 97-2003) SplitSheetsToFiles macros will create single ".xls" files, containing only 1 sheet from source Excel book, the same macro's behavior will be for ".xlsx", ".xlsm", ".xlsb" files (Excel 2007, 2010, 2013).

1. Please download SplitSheetsToFiles archive and unzip it to HDD.

2. Import SplitSheetsToFiles.bas Module into your Excel book (Read How-To). In our SplitSheetsToFiles.xlsm sample workbook contains 3 sheets:

SplitSheetsToFiles_01_3_Sheets_Free-Excel-VBA.Blogspot.com




3. Please return to sheet in your Excel you need to split into single files.

4. Please Save your file into HDD as Macro-Enabled Workbook (.xlsm), if you use Excel 2007, 2010, 2013, etc, or  Excel 97-2003 Workbook (.xls).

5. Press "ALT+F8", select "SplitSheetsToFiles" in "Macro" window and press "Run" button.

6. In a few moments all sheets from your source Excel workbook will are saved into single files at the same folder, which will contains only 1 sheet in each. Here the listing for our SplitSheetsToFiles.xlsm sample workbook

SplitSheetsToFiles_02_File_Listing_After_Splitting_Free-Excel-VBA.Blogspot.com

 SplitSheetsToFiles.bas macros features, limitations and error-protections:
a) Macros will not work until you save file into your HDD. If you open existing Excel workbook with "xlsx" extension, import SplitSheetsToFiles.bas and run it, macros will work.
b) Macros creates single file's extension based on source file extension - for ".xlsx" will are created ".xlsx" files, for "xlsm" - "xlsm", for "xlsb" - "xlsb", for "xls" - "xls", even you use Excel 2007, 2010, 2013, etc.
c) Macros will not erase existing workbook files with same names, it will auto-numerate them until a non-existing filename to save will be found. During auto-numeration macros will not exceed 31 symbols maximum length for sheet name.
d) For Excel 2007, 2010, 2013 users in case of Run-time error '1004': "Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workbook. To move or copy the data to the destination workbook, you can select the data, and then use Copy and Paste commands to insert it into the sheets of another workbook." please do:
Select "File" tab, -> "Options" -> "Save" -> "Save workbooks" section -> "Save files in this format:" -> "Excel Workbook (*.xlsx)" or "Excel Macro-Enabled Workbook (*.xlsm)"
Then Press OK button. Restart the Excel and repeat operation from step 2.

How to make multiple copies of Excel sheet in automatic mode

In this guide will be shown how to make multiple copies of Excel sheet in automatic mode. Two or three sheets could be copied manually very fast, but what about 15 or 50 sheets? Our AutoSheetsCopy macros will make it easily and very fast. It works with any Excel books. Maximum sheets to be added in your book - 1024.

1. Please download AutoSheetsCopy ZIP archive and unzip it to HDD.

2. Import AutoSheetsCopyForm.frm Form file into your Excel book (Read How-To)

3. Import AutoSheetsCopyModule.bas Module file into your Excel book (Read How-To)

4. Please return to sheet in your Excel you need to copy, press "ALT+F8", select "AutoSheetsCopy" in "Macro" window and press "Run" button. Initial User Form with "Auto Sheets Copy" caption will appear.

AutoSheetsCopy_01_Initial_Window_Free-Excel-VBA.Blogspot.com


5. Select (up to 1024) number of copies, then press "Copy" button

AutoSheetsCopy_02_Select_Copies_Free-Excel-VBA.Blogspot.com

6. In a few moments the sheet you have selected will be copied. By default, new sheets will be named as "Sheet1_2", "Sheet1_3", etc. Maximum length of Excel sheet's name is 31.

AutoSheetsCopy_03_Sheet_Copied_Free-Excel-VBA.Blogspot.com