How to get print area range? [closed] - vba

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to create a Save as... button in an UserForm.
When I click it, a dialog appears to save the print area range of activesheet as a *.pdf file.

Here is how to export in PDF the print area of the active sheet :
Dim Ws As Worksheet
Set Ws = ThisWorkbook.ActiveSheet
ws.Range(ws.PageSetup.PrintArea).ExportAsFixedFormat _
Type:=xlTypePDF _
FileName:="sales.pdf" _
Quality:=xlQualityStandard _
DisplayFileAfterPublish:=False
You just need to change "sales.pdf" to fit your purpose! ;)

Related

ExportAsFixedFormat takes very long time [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to save many pdfs but the process of saving via ExportAsFixedFomat takes very long
Do you guys have some idea how to improve my Code (other functions,...)
Code
WordDoc.ExportAsFixedFormat OutputFileName:=wholeString, ExportFormat:=wdExportFormatPDF
Tough to figure out the exact reason in your case. But you can try to deactivate the screen updating like so:
..
Application.ScreenUpdating = False
WordDoc.ExportAsFixedFormat OutputFileName:=wholeString, ExportFormat:=wdExportFormatPDF
Application.ScreenUpdating = True
..
Excel recalculates the workbook before each PDF is generated. Why this should be the case is not immediately obvious. The solution was to insert the following line of code at the beginning of the routine and turn it back to automatic at the end:
Application.Calculation = xlManual
This reduces the total time.

Excel Vba: Finding the Bookmark before a Table on a Word Document [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is there anyway to find the bookmark that exists before a specified table on a word document?
You could use the bookmarks Start or End (range) property to get the ordering of the bookmarks.
Public Sub TestIt()
Dim bm1 As Bookmark
Dim bm2 As Bookmark
Set bm1 = ActiveDocument.Bookmarks("Bookmark1")
Set bm2 = ActiveDocument.Bookmarks("Bookmark2")
If bm1.Start < bm2.Start Then
MsgBox "bm1 is before bm2"
ElseIf bm1.Start > bm2.Start Then
MsgBox "bm2 is before bm1"
Else
MsgBox "bm1 and bm2 start at the same place"
End If
End Sub

How can I integrate Excel with Google Search? <VBA code> [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Goal: get phone numbers in Google trough a table of companies data in Excel
Table: Accounts
Name|Industry|State|City
Hit Combination of Cells and "landline phone" on Google Search and collect in Excel
I'm making this manually. Would love to make it happen trough programing.
Tips and reference coding would help a lot.
Say you have a set of topics on which you wish to do a google search. Place the topics in column A:
The following macro:
Sub dural()
Dim N As Long, i As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook
For i = 1 To N
.FollowHyperlink Address:="https://www.google.com/search?q=" & Cells(i, 1).Value
Next i
End With
End Sub
will open a set of Google search windows. All you need to do is add to the code to:
select the appropriate link
gather data from the web pages.

How can i remove the filter to multiple excel files with visual basic? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have around 500 files of excel and the most part have filter. Now i need to put all information in one sheet. I found how to put all in one sheet but the books with filter only copy information with filter and i need all.
So, i need to remove filter of all excel files. Important (not all files have filter)
Thanks for your help ;)
Before you copy the data, you should use:
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
This will turn off the filter.
Will remove any filter on all opened workbooks, have fun :)
sub try_this()
dim wb as workbook
dim sh as worksheet
for each wb in workbooks
for each sh in wb.worksheets
sh.AutoFilterMode = False
next
next
end sub

Advise for an Excel 2003 VBA video? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I would like to learn how to copy cells from an already open excel workbook to another file. I don't just want a code, I want a tutorial. The problem I have is Google is only giving me forums. Can someone suggest a good tutorial with a video? A hyper link would help.
Option Explicit
Sub CopyFromOpenWorkbookToAnother()
'declare variables
Dim wkbCopy as Workbook, wkbPaste as Workbook
Dim wksCopy as Worksheet, wksPaste as Worksheet
Dim rngCopy as Range
'set variables -> change the names to suit your data needs
Set wkbCopy = Workbooks("WorkbookToCopyFrom.xls")
Set wkbPaste = Workbooks("WorkbookToCopyTo.xls")
Set wksCopy = wkbCopy.Sheets("SheetToCopy")
Set wksPaste = wkbPaste.Sheets("SheetToPaste")
Set rngCopy = wksCopy.Range("A1:A10") 'adjust to whatever range you need
rngCopy.Copy wksPaste.Range("A1") 'adjust to wherever you want to paste
End Sub